Skip to content

Commit 79c9a6a

Browse files
committed
Revert "Allow pick() to work with strict variables"
This reverts commit 2a493ad. This change was not backwards compatible. If a user was using pick with a string that include a $, it would be evaluated and could throw an error. See https://bugs.launchpad.net/tripleo/+bug/1778201
1 parent 4445b08 commit 79c9a6a

2 files changed

Lines changed: 1 addition & 16 deletions

File tree

lib/puppet/parser/functions/pick.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,9 @@ 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-
2518
DOC
2619
) do |args|
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!
20+
args = args.compact
3321
args.delete(:undef)
3422
args.delete(:undefined)
3523
args.delete('')

spec/functions/pick_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
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) }
1512

1613
context 'with UTF8 and double byte characters' do
1714
it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') }

0 commit comments

Comments
 (0)