Skip to content

Commit d25a3e5

Browse files
author
Kevin Paulisse
committed
Pass logger to ENC object execute method
1 parent 050341e commit d25a3e5

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

lib/octocatalog-diff/catalog-util/builddir.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def install_directory_symlink(logger, dir, target = 'environments/production')
195195
def install_enc(logger)
196196
raise ArgumentError, 'A node must be specified when using an ENC' unless @node.is_a?(String)
197197
enc_obj = OctocatalogDiff::CatalogUtil::ENC.new(@options.merge(tempdir: @tempdir))
198+
enc_obj.execute(logger)
198199
raise "Failed ENC: #{enc_obj.error_message}" if enc_obj.error_message
199200

200201
enc_path = File.join(@tempdir, 'enc.sh')

lib/octocatalog-diff/catalog-util/enc.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,29 @@ def initialize(options = {})
3333

3434
# Retrieve content
3535
# @return [String] ENC content, or nil if there was an error
36-
def content
37-
execute
36+
def content(logger = nil)
37+
execute(logger)
3838
@content ||= @enc_obj.content
3939
end
4040

4141
# Retrieve error message
4242
# @return [String] Error message, or nil if there was no error
43-
def error_message
44-
execute
43+
def error_message(logger = nil)
44+
execute(logger)
4545
@error_message ||= @enc_obj.error_message
4646
end
4747

48+
# Execute the 'execute' method of the object, but only once
49+
# @param [Logger] Logger (optional) - if not supplied any logger messages will be discarded
50+
def execute(logger = nil)
51+
return if @executed
52+
logger ||= @options[:logger]
53+
logger ||= Logger.new(StringIO.new)
54+
@enc_obj.execute(logger) if @enc_obj.respond_to?(:execute)
55+
@executed = true
56+
override_enc_parameters(logger)
57+
end
58+
4859
private
4960

5061
# Override of ENC parameters with parameters specified on the command line.
@@ -98,17 +109,6 @@ def backend
98109
# At this point we do not know what backend to use for the ENC
99110
raise ArgumentError, 'Unable to determine ENC backend to use'
100111
end
101-
102-
# Execute the 'execute' method of the object, but only once
103-
# @param [Logger] Logger (optional) - if not supplied any logger messages will be discarded
104-
def execute(logger = nil)
105-
return if @executed
106-
logger ||= @options[:logger]
107-
logger ||= Logger.new(StringIO.new)
108-
@enc_obj.execute(logger) if @enc_obj.respond_to?(:execute)
109-
@executed = true
110-
override_enc_parameters(logger)
111-
end
112112
end
113113
end
114114
end

0 commit comments

Comments
 (0)