Sha256: d66a989a203483483a8120dd1b1e6991701b4b06ade411e167b6071cd17a0ec5

Contents?: true

Size: 908 Bytes

Versions: 14

Compression:

Stored size: 908 Bytes

Contents

require 'open3'

module Gitlab
  module QA
    module Docker
      class Shellout
        StatusError = Class.new(StandardError)

        def initialize(command)
          @command = command
          @output = []

          puts "Docker shell command: `#{@command.mask_secrets}`"
        end

        def execute!
          raise StatusError, 'Command already executed' if @output.any?

          Open3.popen2e(@command.to_s) do |_in, out, wait|
            out.each do |line|
              @output.push(line)

              if block_given?
                yield line, wait
              else
                puts line
              end
            end

            if wait.value.exited? && wait.value.exitstatus.nonzero?
              raise StatusError, "Docker command `#{@command.mask_secrets}` failed!"
            end
          end

          @output.join.chomp
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gitlab-qa-6.6.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.5.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.4.1 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.4.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.3.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.2.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.1.3 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.1.2 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.1.1 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.1.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-6.0.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-5.17.1 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-5.17.0 lib/gitlab/qa/docker/shellout.rb
gitlab-qa-5.16.0 lib/gitlab/qa/docker/shellout.rb