Skip to content

Commit 6c55e13

Browse files
committed
Skip reference validation under puppet 5
1 parent a4425eb commit 6c55e13

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/octocatalog-diff/catalog.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ def validate_references
187187
return
188188
end
189189

190+
# Puppet 5 has reference validation built-in and enabled, so there won't even be a valid catalog if
191+
# there were invalid references. It's pointless to perform validation of our own.
192+
return if puppet_version && puppet_version >= '5.0.0'
193+
190194
# Iterate over all the resources and check each one that has one of the attributes being checked.
191195
# Keep track of all references that are missing for ultimate inclusion in the error message.
192196
missing = []

spec/octocatalog-diff/tests/catalog_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,18 @@
463463
expect(result).to be_nil
464464
end
465465

466+
it 'should not attempt reference validation under puppet 5' do
467+
opts = {
468+
compare_file_text: false,
469+
validate_references: %w(before notify require subscribe),
470+
node: 'my.rspec.node',
471+
json: File.read(OctocatalogDiff::Spec.fixture_path('catalogs/reference-validation-broken.json'))
472+
}
473+
catalog = OctocatalogDiff::Catalog.new(opts)
474+
allow(catalog).to receive(:puppet_version).and_return('5.0.0')
475+
expect { catalog.validate_references }.not_to raise_error
476+
end
477+
466478
it 'should raise error if reference validation is requested' do
467479
opts = {
468480
compare_file_text: false,
@@ -471,6 +483,7 @@
471483
json: File.read(OctocatalogDiff::Spec.fixture_path('catalogs/reference-validation-broken.json'))
472484
}
473485
catalog = OctocatalogDiff::Catalog.new(opts)
486+
allow(catalog).to receive(:puppet_version).and_return('4.10.0')
474487
catalog.compilation_dir = '/var/folders/dw/5ftmkqk972j_kw2fdjyzdqdw0000gn/T/d20161223-46780-x10xaf/environments/production'
475488
error_str = [
476489
'Catalog has broken references: exec[subscribe caller 1](modules/test/manifests/subscribe_callers.pp:2)' \

0 commit comments

Comments
 (0)