Class: Harbor::KamalAdapter::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor/kamal_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:, success:, exit_code:, timed_out:) ⇒ Result

Returns a new instance of Result.



135
136
137
138
139
140
141
# File 'lib/harbor/kamal_adapter.rb', line 135

def initialize(stdout:, stderr:, success:, exit_code:, timed_out:)
  @stdout = stdout
  @stderr = stderr
  @success = success
  @exit_code = exit_code
  @timed_out = timed_out
end

Instance Attribute Details

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



133
134
135
# File 'lib/harbor/kamal_adapter.rb', line 133

def exit_code
  @exit_code
end

#stderrObject (readonly)

Returns the value of attribute stderr.



133
134
135
# File 'lib/harbor/kamal_adapter.rb', line 133

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



133
134
135
# File 'lib/harbor/kamal_adapter.rb', line 133

def stdout
  @stdout
end

Instance Method Details

#error_messageObject



155
156
157
# File 'lib/harbor/kamal_adapter.rb', line 155

def error_message
  @stderr.strip.empty? ? @stdout.strip : @stderr.strip
end

#outputObject



151
152
153
# File 'lib/harbor/kamal_adapter.rb', line 151

def output
  @stdout.strip
end

#success?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/harbor/kamal_adapter.rb', line 143

def success?
  @success
end

#timed_out?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/harbor/kamal_adapter.rb', line 147

def timed_out?
  @timed_out
end

#to_hObject



159
160
161
162
163
164
165
166
167
# File 'lib/harbor/kamal_adapter.rb', line 159

def to_h
  {
    success: @success,
    exit_code: @exit_code,
    output: output,
    error: @success ? nil : error_message,
    timed_out: @timed_out
  }
end