Sha256: 3f569daeb34f54a248fa8f194e1cf3b85a994ed17f76b2b882312e3087491d75
Contents?: true
Size: 1.53 KB
Versions: 44
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module Gitlab module QA module Docker class Command attr_reader :args # Shell command # # @param [<String, Array>] cmd # @param [<String, Array>] mask_secrets # @param [Boolean] stream_output stream command output to stdout directly instead of logger def initialize(cmd = nil, mask_secrets: nil, stream_output: false) @args = Array(cmd) @mask_secrets = Array(mask_secrets) @stream_output = stream_output end def <<(*args) tap { @args.concat(args) } end def volume(from, to, opt = :z) tap { @args.push("--volume #{from}:#{to}:#{opt}") } end def name(identity) tap { @args.push("--name #{identity}") } end def env(name, value) tap { @args.push(%(--env #{name}="#{value}")) } end def port(mapping) tap { @args.push("-p #{mapping}") } end def to_s "docker #{@args.join(' ')}" end def ==(other) to_s == other.to_s end def execute!(&block) Support::ShellCommand.new(to_s, mask_secrets: @mask_secrets, stream_output: @stream_output).execute!(&block) rescue Support::ShellCommand::StatusError => e e.set_backtrace([]) raise e end def self.execute(cmd, mask_secrets: nil, &block) new(cmd, mask_secrets: mask_secrets).execute!(&block) end end end end end
Version data entries
44 entries across 44 versions & 1 rubygems