-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow pick() to work with strict variables #890
Conversation
If `strict_variables` is enabled, then the standard usage of `pick()` will fail. This simply adds the calling convention that strings that look like variables will be resolved if they exist and ignored if they don't.
lib/puppet/parser/functions/pick.rb
Outdated
| # look up the values of any strings that look like '$variables' | ||
| args.map! do |item| | ||
| next unless item.is_a? String | ||
| item.start_with?('$') ? function_getvar([item.slice(1..-1)]) : item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use call_function instead of calling with function_xxx as that only works for 3.x functions.
|
@hlindberg Are you satisfied that the changes that you requested have been made?? |
lib/puppet/parser/functions/pick.rb
Outdated
| args = args.compact | ||
|
|
||
| # look up the values of any strings that look like '$variables' | ||
| args.map! do |item| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should absolutely not mutate the given args!! Must work on a copy. earlier the args.compact provided the copy now this logic will destroy the caller's array of arguments.
|
@binford2k This is currently failing unit and syntax test's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to breaks the pick function if you're using '$variable' as a string option. https://bugs.launchpad.net/tripleo/+bug/1778201
|
sigh - I think this should be reverted as the change is not backwards compatible. |
|
revert #927 |
|
Simple test to exhibit the issue is: $g = pick('$something', '$somethingelse') Will fail with, |
[1] is breaking TripleO deployments, see https://bugs.launchpad.net/tripleo/+bug/1778201 [1] - puppetlabs/puppetlabs-stdlib#890 Change-Id: I7cb4eeb7360ac458803a2926bd15183f69f9a35e
|
For those that want to avoid errors with strict variables, there are other functions to use besides |
If
strict_variablesis enabled, then the standard usage ofpick()will fail. This simply adds the calling convention that strings that
look like variables will be resolved if they exist and ignored if they
don't.