Skip to content

Commit f650537

Browse files
author
Kevin Paulisse
committed
Add --no-validate-references to specify nothing to be validated
1 parent 12e1e87 commit f650537

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

lib/octocatalog-diff/catalog-diff/cli/options/validate_references.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
has_weight 205
1010

1111
def parse(parser, options)
12-
parser.on('--validate-references "before,require,subscribe,notify"', Array, 'References to validate') do |res|
13-
options[:validate_references] ||= []
14-
res.each do |item|
15-
unless %w(before require subscribe notify).include?(item)
16-
raise ArgumentError, "Invalid reference validation #{item}"
17-
end
12+
parser.on('--[no-]validate-references "before,require,subscribe,notify"', Array, 'References to validate') do |res|
13+
if res == false
14+
options[:validate_references] = []
15+
else
16+
options[:validate_references] ||= []
17+
res.each do |item|
18+
unless %w(before require subscribe notify).include?(item)
19+
raise ArgumentError, "Invalid reference validation #{item}"
20+
end
1821

19-
options[:validate_references] << item
22+
options[:validate_references] << item
23+
end
2024
end
2125
end
2226
end

spec/octocatalog-diff/integration/reference_validation_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def self.catalog_contains_resource(result, type, title)
3535

3636
describe 'validation specifically disabled' do
3737
before(:all) do
38-
argv = ['--catalog-only', '-n', 'rspec-node.github.net', '--no-reference-validation']
38+
argv = ['--catalog-only', '-n', 'rspec-node.github.net', '--no-validate-references']
3939
@result = OctocatalogDiff::Integration.integration(
4040
hiera_config: 'hiera.yaml',
4141
spec_fact_file: 'facts.yaml',
@@ -45,7 +45,7 @@ def self.catalog_contains_resource(result, type, title)
4545
end
4646

4747
it 'should return the valid catalog' do
48-
expect(@result.exitcode).to eq(2)
48+
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
4949
end
5050
end
5151

spec/octocatalog-diff/tests/catalog-diff/cli/options/validate_references_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
expect(result[:validate_references]).to eq(%w(before require notify subscribe))
2020
end
2121

22+
it 'should accept negative' do
23+
result = run_optparse(['--no-validate-references'])
24+
expect(result[:validate_references]).to eq([])
25+
end
26+
2227
it 'should fail for an invalid argument' do
2328
expect { run_optparse(['--validate-references', 'chicken']) }.to raise_error(ArgumentError, /Invalid reference validation/)
2429
end

0 commit comments

Comments
 (0)