Sha256: e3c4aa4e7e25af4eba3be67544c0571648a40f0230414fadf89b00bfa818365c
Contents?: true
Size: 1.45 KB
Versions: 112
Compression:
Stored size: 1.45 KB
Contents
module Gitlab module QA module Docker class Command attr_reader :args def initialize(cmd = nil, mask_secrets: nil) @args = Array(cmd) @mask_secrets = Array(mask_secrets) 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 to_s "docker #{@args.join(' ')}" end # Returns a masked string form of a Command # # @example # Command.new('a docker command', mask_secrets: 'command').mask_secrets #=> 'a docker *****' # Command.new('a docker command', mask_secrets: %w[docker command]).mask_secrets #=> 'a ***** *****' # # @return [String] The masked command string def mask_secrets @mask_secrets.each_with_object(to_s) { |secret, s| s.gsub!(secret, '*****') } end def ==(other) to_s == other.to_s end def execute!(&block) Docker::Shellout.new(self).execute!(&block) 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
112 entries across 112 versions & 1 rubygems