Skip to content

Commit f4a94d3

Browse files
committed
add --top-scope-variables cli argument, fix #228
1 parent 002f275 commit f4a94d3

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

lib/puppet-lint/optparser.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ def self.build(args = [])
128128
PuppetLint.configuration.ignore_paths = paths.split(',')
129129
end
130130

131+
opts.on('--top-scope-variables VARS', 'A comma separated list of allowed top scope variables') do |vars|
132+
PuppetLint.configuration.top_scope_variables = vars.split(',')
133+
end
134+
131135
PuppetLint.configuration.checks.each do |check|
132136
opts.on("--no-#{check}-check", "Skip the #{check} check.") do
133137
PuppetLint.configuration.send(:"disable_#{check}")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# foo
2+
define test::top_scope_variables() {
3+
notice($role)
4+
}

spec/unit/puppet-lint/bin_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ def initialize(args)
121121
its(:stdout) { is_expected.to eq('') }
122122
end
123123

124+
context 'when passed top scope variables option' do
125+
let(:args) do
126+
[
127+
'--top-scope-variables=role',
128+
'spec/fixtures/test/manifests/top_scope_variables.pp',
129+
]
130+
end
131+
132+
its(:exitstatus) { is_expected.to eq(0) }
133+
its(:stdout) { is_expected.to eq('') }
134+
end
135+
124136
context 'when limited to errors only' do
125137
let(:args) do
126138
[

0 commit comments

Comments
 (0)