diff --git a/lib/puppet-lint/optparser.rb b/lib/puppet-lint/optparser.rb index 4dcb2930b..61a3fb5a7 100644 --- a/lib/puppet-lint/optparser.rb +++ b/lib/puppet-lint/optparser.rb @@ -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}") diff --git a/spec/fixtures/test/manifests/top_scope_variables.pp b/spec/fixtures/test/manifests/top_scope_variables.pp new file mode 100644 index 000000000..1fff0a8b9 --- /dev/null +++ b/spec/fixtures/test/manifests/top_scope_variables.pp @@ -0,0 +1,4 @@ +# foo +define test::top_scope_variables() { + notice($role) +} diff --git a/spec/unit/puppet-lint/bin_spec.rb b/spec/unit/puppet-lint/bin_spec.rb index 118d054b9..542ef7e6a 100644 --- a/spec/unit/puppet-lint/bin_spec.rb +++ b/spec/unit/puppet-lint/bin_spec.rb @@ -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 [