X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fgetvar.rb;h=41d3c4f4119f985900302930bac147680e4efdeb;hp=fddbd82f0db126bd07be930c4ed16dc9264e32a3;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb index fddbd82f0..41d3c4f41 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb @@ -3,21 +3,20 @@ # module Puppet::Parser::Functions newfunction(:getvar, :type => :rvalue, :doc => <<-'DOC') do |args| - Lookup a variable in a given namespace. - Returns undef if variable does not exist. + @summary + Lookup a variable in a given namespace. - For example: + @return + undef - if variable does not exist - $foo = getvar('site::data::foo') - # Equivalent to $foo = $site::data::foo + @example Example usage + $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo - This is useful if the namespace itself is stored in a string: + @example Where namespace is stored in a string + $datalocation = 'site::data' + $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar - $datalocation = 'site::data' - $bar = getvar("${datalocation}::bar") - # Equivalent to $bar = $site::data::bar - - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core + > **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core will be used instead of this function. The new function also has support for digging into a structured value. See the built-in [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) function