Puppet Function: loki::strip_yaml_header

Defined in:
lib/puppet/functions/loki/strip_yaml_header.rb
Function type:
Ruby 4.x API

Overview

loki::strip_yaml_header(String $yaml_string)String

A function to strip the — from the beginning of a string

Examples:

concat::fragment { 'loki_common_config':
  target  => $config_file,
  content => $loki::common_config_hash.stdlib::to_yaml.loki::strip_yaml_header,
  order   => '09',
}

Parameters:

  • yaml_string (String)

    A string that may start with the —‘s used to denote a YAML file

Returns:

  • (String)

    Returns the string with the leading header stripped off



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/functions/loki/strip_yaml_header.rb', line 2

Puppet::Functions.create_function(:'loki::strip_yaml_header') do
  # @param yaml_string
  #   A string that may start with the ---'s used to denote a YAML file
  # @return [String]
  #   Returns the string with the leading header stripped off
  # @example
  #   concat::fragment { 'loki_common_config':
  #     target  => $config_file,
  #     content => $loki::common_config_hash.stdlib::to_yaml.loki::strip_yaml_header,
  #     order   => '09',
  #   }
  #
  dispatch :strip_header do
    param 'String', :yaml_string
    return_type 'String'
  end

  def strip_header(yaml_string)
    yaml_string.gsub(%r{^---\s}, '')
  end
end