Sha256: b8bc187328f5f5fafecb3490c83e7f849d4a2757f550d60c1629afc8afdab5ee
Contents?: true
Size: 834 Bytes
Versions: 4
Compression:
Stored size: 834 Bytes
Contents
# @since 4.8.0 # require 'yaml' Puppet::Functions.create_function(:yaml_data) do dispatch :yaml_data do param 'Struct[{path=>String[1]}]', :options param 'Puppet::LookupContext', :context end def yaml_data(options, context) path = options['path'] context.cached_file_data(path) do |content| begin data = YAML.load(content, path) if data.is_a?(Hash) Puppet::Pops::Lookup::HieraConfig.symkeys_to_string(data) else Puppet.warning("#{path}: file does not contain a valid yaml hash") {} end rescue YAML::SyntaxError => ex # Psych errors includes the absolute path to the file, so no need to add that # to the message raise Puppet::DataBinding::LookupError, "Unable to parse #{ex.message}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems