Skip to content

Commit

Permalink
add --top-scope-variables cli argument, fix #228
Browse files Browse the repository at this point in the history
  • Loading branch information
jcharaoui committed Jan 30, 2025
1 parent 002f275 commit f4a94d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/puppet-lint/optparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def self.build(args = [])
PuppetLint.configuration.ignore_paths = paths.split(',')
end

opts.on('--top-scope-variables VARS', 'A comma separated list of allowed top scope variables') do |vars|
PuppetLint.configuration.top_scope_variables = vars.split(',')
end

PuppetLint.configuration.checks.each do |check|
opts.on("--no-#{check}-check", "Skip the #{check} check.") do
PuppetLint.configuration.send(:"disable_#{check}")
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/test/manifests/top_scope_variables.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# foo
define test::top_scope_variables() {
notice($role)
}
12 changes: 12 additions & 0 deletions spec/unit/puppet-lint/bin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ def initialize(args)
its(:stdout) { is_expected.to eq('') }
end

context 'when passed top scope variables option' do
let(:args) do
[
'--top-scope-variables=role',
'spec/fixtures/test/manifests/top_scope_variables.pp',
]
end

its(:exitstatus) { is_expected.to eq(0) }
its(:stdout) { is_expected.to eq('') }
end

context 'when limited to errors only' do
let(:args) do
[
Expand Down

0 comments on commit f4a94d3

Please sign in to comment.