Method: Puppet::Pops::Lookup::ModuleDataProvider#validate_data_hash

Defined in:
lib/puppet/pops/lookup/module_data_provider.rb

#validate_data_hash(data_hash) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Asserts that all keys in the given data_hash are prefixed with the configured module_name. Removes entries that does not follow the convention and logs a warning.

Parameters:

  • data_hash (Hash)

    The data hash

Returns:

  • (Hash)

    The possibly pruned hash



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 46

def validate_data_hash(data_hash)
  super
  module_prefix = "#{module_name}::"
  data_hash.each_key.reduce(data_hash) do |memo, k|
    next memo if k == LOOKUP_OPTIONS || k.start_with?(module_prefix)
    msg = "#{yield} must use keys qualified with the name of the module"
    memo = memo.clone if memo.equal?(data_hash)
    memo.delete(k)
    Puppet.warning("Module '#{module_name}': #{msg}")
    memo
  end
  data_hash
end