Skip to content

Commit 3c4eec0

Browse files
committed
Separate method for checking compare-file-text from doing it
1 parent d1aa01d commit 3c4eec0

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

lib/octocatalog-diff/catalog.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ def retries
202202
nil
203203
end
204204

205+
# By default, catalogs do not support converting and comparing file resources. This can be overridden
206+
# by backends that do support it.
207+
def supports_compare_file_text?
208+
false
209+
end
210+
205211
# Determine if the catalog build was successful.
206212
# @return [Boolean] Whether the catalog is valid
207213
def valid?

lib/octocatalog-diff/catalog/computed.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def convert_file_resources(logger = Logger.new(StringIO.new))
7171
convert_file_resources_real(logger)
7272
end
7373

74+
def supports_compare_file_text?
75+
true
76+
end
77+
7478
private
7579

7680
# Private method: Clean up a checkout directory, if it exists
@@ -124,7 +128,7 @@ def bootstrap(logger)
124128

125129
# Private method: Build catalog by running Puppet
126130
# @param logger [Logger] Logger object
127-
def build_catalog(logger = nil)
131+
def build_catalog(logger)
128132
if @facts_terminus != 'facter'
129133
facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger)
130134
logger.debug "Start retrieving facts for #{@node} from #{self.class}"

lib/octocatalog-diff/catalog/json.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def initialize(options)
3333
def convert_file_resources(logger = Logger.new(StringIO.new))
3434
convert_file_resources_real(logger)
3535
end
36+
37+
def supports_compare_file_text?
38+
true
39+
end
3640
end
3741
end
3842
end

lib/octocatalog-diff/util/catalogs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def build_catalog_parallelizer
7070
# Disable --compare-file-text if either (or both) of the chosen backends do not support it
7171
if @options.fetch(:compare_file_text, false)
7272
result.each do |_key, val|
73-
next unless val.convert_file_resources == false
73+
next if val.supports_compare_file_text?
7474
@logger.debug "Disabling --compare-file-text; not supported by #{val.builder}"
7575
@options[:compare_file_text] = false
7676
catalog_tasks.map! do |x|

0 commit comments

Comments
 (0)