Lookup configuration setting value through a chain of different value sources.
@api public
Lookup the interpolated value. All instances of `$name` in the value will be replaced by performing a lookup of `name` and substituting the text for `$name` in the original value. This interpolation is only performed if the looked up value is a String.
@param name [Symbol] The configuration setting name to look up @return [Object] The configuration setting value or nil if the setting is not known @api public
# File lib/puppet/settings.rb, line 1304 def interpolate(name) setting = @defaults[name] if setting val = lookup(name) # if we interpolate code, all hell breaks loose. if name == :code val else # Convert it if necessary begin val = convert(val, name) rescue InterpolationError => err # This happens because we don't have access to the param name when the # exception is originally raised, but we want it in the message raise InterpolationError, "Error converting value for param '#{name}': #{err}", err.backtrace end setting.munge(val) end else nil end end
Lookup the uninterpolated value.
@param name [Symbol] The configuration setting name to look up @return [Object] The configuration setting value or nil if the setting is not known @api public
# File lib/puppet/settings.rb, line 1282 def lookup(name) set = @value_sets.find do |set| set.include?(name) end if set value = set.lookup(name) if !value.nil? return value end end @defaults[name].default end
@see Puppet::Settings#values @api private
# File lib/puppet/settings.rb, line 1270 def initialize(mode, environment, value_sets, defaults) @mode = mode @environment = environment @value_sets = value_sets @defaults = defaults end