Class: Puppet::DataProviders::JsonDataProvider

Inherits:
Plugins::DataProviders::PathBasedDataProvider show all
Includes:
HieraInterpolate
Defined in:
lib/puppet/data_providers/json_data_provider_factory.rb

Instance Attribute Summary

Attributes inherited from Plugins::DataProviders::PathBasedDataProvider

#name

Instance Method Summary collapse

Methods included from HieraInterpolate

#interpolate

Methods inherited from Plugins::DataProviders::PathBasedDataProvider

#initialize, #load_data, #unchecked_lookup, #validate_data

Methods included from Plugins::DataProviders::DataProvider

#data_key, #lookup, #name, #unchecked_lookup, #validate_data

Constructor Details

This class inherits a constructor from Puppet::Plugins::DataProviders::PathBasedDataProvider

Instance Method Details

#initialize_data(path, lookup_invocation) ⇒ Object



20
21
22
23
24
25
# File 'lib/puppet/data_providers/json_data_provider_factory.rb', line 20

def initialize_data(path, lookup_invocation)
  JSON.parse(File.read(path))
rescue JSON::ParserError => ex
  # Filename not included in message, so we add it here.
  raise Puppet::DataBinding::LookupError, "Unable to parse (#{path}): #{ex.message}"
end

#post_process(value, lookup_invocation) ⇒ Object



27
28
29
# File 'lib/puppet/data_providers/json_data_provider_factory.rb', line 27

def post_process(value, lookup_invocation)
  interpolate(value, lookup_invocation, true)
end