Class: Gitlab::QA::Docker::Shellout
- Inherits:
-
Object
- Object
- Gitlab::QA::Docker::Shellout
- Defined in:
- lib/gitlab/qa/docker/shellout.rb
Constant Summary collapse
- StatusError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#execute! ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(command) ⇒ Shellout
constructor
A new instance of Shellout.
Constructor Details
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
20 21 22 |
# File 'lib/gitlab/qa/docker/shellout.rb', line 20 def command @command end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
20 21 22 |
# File 'lib/gitlab/qa/docker/shellout.rb', line 20 def output @output end |
Instance Method Details
#execute! ⇒ Object
rubocop:disable Metrics/AbcSize
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/qa/docker/shellout.rb', line 22 def execute! # rubocop:disable Metrics/AbcSize raise StatusError, 'Command already executed' if output.any? logger.info("Docker shell command: `#{command.mask_secrets.cyan}`") Open3.popen2e(@command.to_s) do |_in, out, wait| out.each do |line| output.push(line) if stream_progress print "." elsif command.stream_output puts line end yield line, wait if block_given? end puts if stream_progress && !output.empty? fail! if wait.value.exited? && wait.value.exitstatus.nonzero? logger.debug("Docker shell command output:\n#{string_output}") unless command.stream_output || output.empty? end string_output end |