Allow pick() to work with strict variables#890
Allow pick() to work with strict variables#890david22swan merged 4 commits intopuppetlabs:masterfrom binford2k:pick_undefined_vars
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.
| # 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.
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?? |
| 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.
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 |
mwhahaha
left a comment
There was a problem hiding this comment.
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.