File tree Expand file tree Collapse file tree
lib/puppet/parser/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,9 +15,21 @@ module Puppet::Parser::Functions
1515 called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
1616 Enterprise Console are brought into Puppet as top-scope variables), and,
1717 failing that, will use a default value of 1.449.
18+
19+ If you have `strict_variables` turned on, then wrap your variable in single
20+ quotes to prevent interpolation and this function will check to see if that
21+ variable exists.
22+
23+ $real_jenkins_version = pick('$::jenkins_version', '1.449')
24+
1825DOC
1926 ) do |args |
20- args = args . compact
27+ # look up the values of any strings that look like '$variables' w/o mutating args
28+ args = args . map do |item |
29+ next item unless item . is_a? String
30+ item . start_with? ( '$' ) ? call_function ( 'getvar' , [ item . slice ( 1 ..-1 ) ] ) : item
31+ end
32+ args . compact!
2133 args . delete ( :undef )
2234 args . delete ( :undefined )
2335 args . delete ( '' )
Original file line number Diff line number Diff line change 99 it { is_expected . to run . with_params ( :undef , 'two' ) . and_return ( 'two' ) }
1010 it { is_expected . to run . with_params ( :undefined , 'two' ) . and_return ( 'two' ) }
1111 it { is_expected . to run . with_params ( nil , 'two' ) . and_return ( 'two' ) }
12+ it { is_expected . to run . with_params ( '$foo' , 'two' ) . and_return ( 'two' ) }
13+ it { is_expected . to run . with_params ( '$puppetversion' , 'two' ) . and_return ( Puppet . version ) }
14+ it { is_expected . to run . with_params ( '$::puppetversion' , 'two' ) . and_return ( Puppet . version ) }
1215
1316 context 'with UTF8 and double byte characters' do
1417 it { is_expected . to run . with_params ( nil , 'このテキスト' ) . and_return ( 'このテキスト' ) }
You can’t perform that action at this time.
0 commit comments