Skip to content

Commit b850dd9

Browse files
committed
Explicitly skip reference validation for to-catalog
1 parent 2d28eb7 commit b850dd9

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/octocatalog-diff/catalog.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ def initialize(options = {})
3636
# The compilation directory can be overridden, e.g. when testing
3737
@override_compilation_dir = options[:compilation_dir]
3838

39+
# Keep track of whether references have been validated yet. Allow this to be fudged for when we do
40+
# not desire reference validation to happen (e.g., for the "from" catalog that is otherwise valid).
41+
@references_validated = options[:references_validated] || false
42+
3943
# Call appropriate backend for catalog generation
4044
@catalog_obj = backend(options)
4145

4246
# The catalog is not built yet, except if the backend has no build method
4347
@built = false
4448
build unless @catalog_obj.respond_to?(:build)
45-
46-
# Keep track of whether references have been validated yet
47-
@references_validated = false
4849
end
4950

5051
# Build catalog - this method needs to be called to build the catalog. It is separate due to

lib/octocatalog-diff/util/catalogs.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def build_catalog_tasks
157157
args.delete(opt_key)
158158
end
159159

160+
# Skip reference validation in the from-catalog by saying we already performed it.
161+
args[:references_validated] = (key == :from)
162+
160163
# The task is a OctocatalogDiff::Util::Parallel::Task object that contains the method to execute,
161164
# validator method, text description, and arguments to provide when calling the method.
162165
task = OctocatalogDiff::Util::Parallel::Task.new(
@@ -250,10 +253,9 @@ def build_catalog(opts, logger = @logger)
250253
# @param logger [Logger] Logger object (presently unused)
251254
# @param args [Hash] Additional arguments set specifically for validator
252255
# @return [Boolean] Return true if catalog is valid, false otherwise
253-
def catalog_validator(catalog = nil, _logger = @logger, args = {})
256+
def catalog_validator(catalog = nil, _logger = @logger, _args = {})
254257
raise ArgumentError, "Expects a catalog, got #{catalog.class}" unless catalog.is_a?(OctocatalogDiff::Catalog)
255258
raise OctocatalogDiff::Errors::CatalogError, "Catalog failed: #{catalog.error_message}" unless catalog.valid?
256-
catalog.validate_references if args[:task] == :to # Raises exception for broken references
257259
true
258260
end
259261
end

spec/octocatalog-diff/integration/reference_validation_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def self.catalog_contains_resource(result, type, title)
336336
expect(@result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(@result)
337337
end
338338

339-
it 'should raise ReferenceValidationError' do
340-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::ReferenceValidationError)
339+
it 'should raise CatalogError' do
340+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
341341
end
342342

343343
# rubocop:disable Metrics/LineLength
@@ -382,8 +382,8 @@ def self.catalog_contains_resource(result, type, title)
382382
expect(@result.exitcode).to eq(-1), @result.logs
383383
end
384384

385-
it 'should raise ReferenceValidationError' do
386-
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::ReferenceValidationError)
385+
it 'should raise CatalogError' do
386+
expect(@result.exception).to be_a_kind_of(OctocatalogDiff::Errors::CatalogError)
387387
end
388388

389389
# rubocop:disable Metrics/LineLength

0 commit comments

Comments
 (0)