-
Notifications
You must be signed in to change notification settings - Fork 612
Fix postgresql::default()
return value for unknown parameters
#1530
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
Conversation
9ce58b1
to
587e488
Compare
When calling `postgresql::default()` with a name that has no corresponding parameter, the function returns the string "postgresql::globals::<parameter-name>" which is probably not intended given the comment above the code. The usage of pick seems to indicate that an exception should be raised when a parameter is not found in `params` nor `globals.pp`, so adjust the code accordingly.
`postgresql::params` inherits from `postgresql::globals` so any variable defined in `postgresql::globals` can be accessed by reading it from `postgresql::params`, making it redundant to check both. diff --git a/functions/default.pp b/functions/default.pp index e36610b..41b5006 100644 --- a/functions/default.pp +++ b/functions/default.pp @@ -8,8 +8,7 @@ function postgresql::default( ) { include postgresql::params - #search for the variable name in params first - #then fall back to globals if not found - pick(getvar("postgresql::params::${parameter_name}"), - getvar("postgresql::globals::${parameter_name}")) + # Search for the variable name in params. + # params inherits from globals, so it will also catch these variables. + pick(getvar("postgresql::params::${parameter_name}")) }
587e488
to
6cb50cb
Compare
"postgresql::globals::${parameter_name}") | ||
# Search for the variable name in params. | ||
# params inherits from globals, so it will also catch these variables. | ||
pick(getvar("postgresql::params::${parameter_name}")) |
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.
Late to the party, but what's the point of using pick()
with a single parameter? Isn't just getvar()
the same?
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.
getvar('nothing_here')
returns undef
. Since pick was already there, I assumed we wanted to have a strong failure with an exception in that case.
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.
I suspected that, but good to hear that explicitly.
When calling
postgresql::default()
with a name that has no corresponding parameter, the function returns the string "postgresql::globals::" which is probably not intended given the comment above the code.The usage of pick seems to indicate that an exception should be raised when a parameter is not found in
params
norglobals.pp
, so adjust the code accordingly.