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

plugin converts scoped variables into $facts hash #10

Open
KeithWard opened this issue Apr 20, 2022 · 3 comments · May be fixed by #11
Open

plugin converts scoped variables into $facts hash #10

KeithWard opened this issue Apr 20, 2022 · 3 comments · May be fixed by #11

Comments

@KeithWard
Copy link

KeithWard commented Apr 20, 2022

We've noticed that the current behaviour of this plugin seems to conflict with other plugins.

There's some history in puppetlabs/puppet-lint#41

Most notably this plugin seems to want to convert all variables with $:: to top level facts, even if they're scoped variables, which results in some weird syntax depending on which plugin gets there first.

Example:
It attempts to convert: $::myodule::foo
Into: $facts['mymodule']::foo

However In the event that the topscope_variable plugin gets there first, it'll give you a more reasonable:
use $mymodule::foo instead of $::mymodule::foo

The shortest solution i can think of for this, is similar to Alex's solution for voxpupuli/puppet-lint-topscope-variable-check#12 where we exclude anything ending in ::

@alexjfisher
Copy link

In the event that the topscope_variable plugin gets there first

It comes second alphabetically, so AFAICT, will be registered after this plugin and will be run after too??

@natemccurdy
Copy link

This plugin at version 1.0.1 is also erroring on top-scope variables from manifests/site.pp and the ENC.

For example, this:

notice($::some_top_scope_var)
notice($::a_var_from_an_enc)

Throws this error:

foo.pp - WARNING:top_scope_facts - top scope fact instead of facts hash on line 1
foo.pp - WARNING:top_scope_facts - top scope fact instead of facts hash on line 2

And thinking about it... how is this plugin supposed to know what's a fact and what's a real top-scope variable?

@natemccurdy
Copy link

Ah, ignore my last question.. it's right in the docs: https://github.com/mmckinst/puppet-lint-top_scope_facts-check#configuring-the-check

The list of top-scope-variables can be configured.

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