Class: Gitlab::QA::Docker::Command
- Inherits:
-
Object
- Object
- Gitlab::QA::Docker::Command
- Defined in:
- lib/gitlab/qa/docker/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(*args) ⇒ Object
- #==(other) ⇒ Object
- #env(name, value) ⇒ Object
- #execute!(&block) ⇒ Object
-
#initialize(cmd = nil, mask_secrets: nil, stream_output: false) ⇒ Command
constructor
Shell command.
- #name(identity) ⇒ Object
- #port(mapping) ⇒ Object
- #to_s ⇒ Object
- #volume(from, to, opt = :z) ⇒ Object
Constructor Details
#initialize(cmd = nil, mask_secrets: nil, stream_output: false) ⇒ Command
Shell command
14 15 16 17 18 |
# File 'lib/gitlab/qa/docker/command.rb', line 14 def initialize(cmd = nil, mask_secrets: nil, stream_output: false) @args = Array(cmd) @mask_secrets = mask_secrets @stream_output = stream_output end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
7 8 9 |
# File 'lib/gitlab/qa/docker/command.rb', line 7 def args @args end |
Class Method Details
.execute(cmd, mask_secrets: nil, &block) ⇒ Object
56 57 58 |
# File 'lib/gitlab/qa/docker/command.rb', line 56 def self.execute(cmd, mask_secrets: nil, &block) new(cmd, mask_secrets: mask_secrets).execute!(&block) end |
Instance Method Details
#<<(*args) ⇒ Object
20 21 22 |
# File 'lib/gitlab/qa/docker/command.rb', line 20 def <<(*args) tap { @args.concat(args) } end |
#==(other) ⇒ Object
44 45 46 |
# File 'lib/gitlab/qa/docker/command.rb', line 44 def ==(other) to_s == other.to_s end |
#env(name, value) ⇒ Object
32 33 34 |
# File 'lib/gitlab/qa/docker/command.rb', line 32 def env(name, value) tap { @args.push(%(--env #{name}="#{value}")) } end |
#execute!(&block) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/gitlab/qa/docker/command.rb', line 48 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 |
#name(identity) ⇒ Object
28 29 30 |
# File 'lib/gitlab/qa/docker/command.rb', line 28 def name(identity) tap { @args.push("--name #{identity}") } end |
#port(mapping) ⇒ Object
36 37 38 |
# File 'lib/gitlab/qa/docker/command.rb', line 36 def port(mapping) tap { @args.push("-p #{mapping}") } end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/gitlab/qa/docker/command.rb', line 40 def to_s "docker #{@args.join(' ')}" end |
#volume(from, to, opt = :z) ⇒ Object
24 25 26 |
# File 'lib/gitlab/qa/docker/command.rb', line 24 def volume(from, to, opt = :z) tap { @args.push("--volume #{from}:#{to}:#{opt}") } end |