Skip to content
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

Modify params_lookup() to be able to search module::varname #92

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

javierbertoli
Copy link

Hi Al,

This patch adds a few extra lookups as we discussed a while ago, to let current 2.x modules to lookup hiera variables as proposed by puppet standards, module::varname.

Also, as an extra, I've updated the specs to run OK with rspec 1.0.

Regards, Javier

@alvagante
Copy link
Member

Up to now I've avoided to add the module::param lookup because it's basically useless: the default hiera lookup in Puppet3 is done in any case, so actually the module::param notation works also with current params_lookup, the only issue being that it can't be merged for a global lookup ( if you have both module::param and param the latter is used).
But since the current behaviour for module::param is what will happen when we'll remove params_lookup, I prefer to keep it as it.
The other fixes to the spec tests are perfect, so would you maend the changes to params_lookup (and the relevant tests? eventually converting them to test that verify the current behavior)

@javierbertoli
Copy link
Author

Emmm... surely I'm missing something here, but suppose you have this module/manifests/init.pp

class bla (
  somevar = params_lookup( 'somevar')
....
) {}

that call to param_lookup() will fall into lib/puppet/parser/functions/params_lookup.rb:

function_hiera(["#{module_name}_#{var_name}", ''])`.

or into

function_hiera(["#{var_name}", '']) if arguments[1] == 'global'

And the searches with lookupvar() follows the same logic.

I fail to see where bla::somevar will be searched for, as all the search calls have '_' hardcoded.

I also remember (blurrily) trying module::var when we discussed this and it failed to return the values from hiera.

Am I all wrong?

@Poil
Copy link
Contributor

Poil commented Mar 13, 2015

params_lookup return '' (empty string) if it cannot find a value. but puppet will lookup for ::class::variable before running the params_lookup

I really don't understand why params_lookup return an empty string and not undef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants