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

Stop using scope.lookupvar() in templates #701

Closed
ghoneycutt opened this issue Jun 30, 2017 · 5 comments
Closed

Stop using scope.lookupvar() in templates #701

ghoneycutt opened this issue Jun 30, 2017 · 5 comments
Assignees

Comments

@ghoneycutt
Copy link
Collaborator

We should bring the variables into the local scope and use @variable

https://docs.puppet.com/puppet/4.10/lang_template_erb.html#accessing-puppet-variables

@Phil-Friderici
Copy link
Collaborator

If we move the variables to the classes where they are really used, we will break backward compatibility.
For example the template sensu.erb is used in sensu::package but the variables are sourced in from the main class.

To maintain backward compatibility in the first step, I could add the variables to sensu::package and source them in from the main class. This way you get the same results using the old way.

class sensu::package (
  $log_dir = $::sensu::log_dir,
  ) {

@ghoneycutt
Copy link
Collaborator Author

Let's go the second route and do variable assignment that references variables in the main class. Eventually I'd like to collapse all these extra classes and this will make it easier to understand where the variables come from.

Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 9, 2017
Add tests for existing functionality as preparation.
@Phil-Friderici
Copy link
Collaborator

Working on this in PR #724

Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 9, 2017
Add tests for existing functionality as preparation.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 9, 2017
Use local variables that reference to main class.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 11, 2017
Add tests for existing functionality as preparation.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 11, 2017
Use local variables that reference to main class.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 11, 2017
Use local variables that reference to main class.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 11, 2017
Add tests for existing functionality as proof for backward compatibility.
Phil-Friderici added a commit to Phil-Friderici/sensu-puppet that referenced this issue Jul 13, 2017
Add tests for existing functionality as proof for backward compatibility.
ghoneycutt added a commit that referenced this issue Jul 13, 2017
(GH-701) Stop using scope.lookupvar() in templates
@Phil-Friderici
Copy link
Collaborator

this issue can be closed now :)

@ghoneycutt
Copy link
Collaborator Author

Released in v2.22.0

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

No branches or pull requests

2 participants