vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb in bolt-0.20.5

- old
+ new

@@ -1,7 +1,7 @@ # The `eyaml_lookup_key` is a hiera 5 `lookup_key` data provider function. -# See [the configuration guide documentation](https://docs.puppet.com/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-hiera-eyaml) for +# See [the configuration guide documentation](https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-hiera-eyaml) for # how to use this function. # # @since 5.0.0 # Puppet::Functions.create_function(:eyaml_lookup_key) do @@ -48,10 +48,12 @@ 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") % { path: path }) + msg = _("%{path}: file does not contain a valid yaml hash") % { path: path } + raise Puppet::DataBinding::LookupError, msg if Puppet[:strict] == :error && data != false + Puppet.warning(msg) {} end rescue YAML::SyntaxError => ex # Psych errors includes the absolute path to the file, so no need to add that # to the message