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.
-
#stream_output ⇒ Object
readonly
Returns the value of attribute stream_output.
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.
-
#mask_secrets ⇒ String
Returns a masked string form of a Command.
- #name(identity) ⇒ Object
- #to_s ⇒ Object
- #volume(from, to, opt = :z) ⇒ Object
Constructor Details
#initialize(cmd = nil, mask_secrets: nil, stream_output: false) ⇒ Command
Shell command
12 13 14 15 16 |
# File 'lib/gitlab/qa/docker/command.rb', line 12 def initialize(cmd = nil, mask_secrets: nil, stream_output: false) @args = Array(cmd) @mask_secrets = Array(mask_secrets) @stream_output = stream_output end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/gitlab/qa/docker/command.rb', line 5 def args @args end |
#stream_output ⇒ Object (readonly)
Returns the value of attribute stream_output.
5 6 7 |
# File 'lib/gitlab/qa/docker/command.rb', line 5 def stream_output @stream_output end |
Class Method Details
.execute(cmd, mask_secrets: nil, &block) ⇒ Object
57 58 59 |
# File 'lib/gitlab/qa/docker/command.rb', line 57 def self.execute(cmd, mask_secrets: nil, &block) new(cmd, mask_secrets: mask_secrets).execute!(&block) end |
Instance Method Details
#<<(*args) ⇒ Object
18 19 20 |
# File 'lib/gitlab/qa/docker/command.rb', line 18 def <<(*args) tap { @args.concat(args) } end |
#==(other) ⇒ Object
49 50 51 |
# File 'lib/gitlab/qa/docker/command.rb', line 49 def ==(other) to_s == other.to_s end |
#env(name, value) ⇒ Object
30 31 32 |
# File 'lib/gitlab/qa/docker/command.rb', line 30 def env(name, value) tap { @args.push(%(--env #{name}="#{value}")) } end |
#execute!(&block) ⇒ Object
53 54 55 |
# File 'lib/gitlab/qa/docker/command.rb', line 53 def execute!(&block) Docker::Shellout.new(self).execute!(&block) end |
#mask_secrets ⇒ String
Returns a masked string form of a Command
45 46 47 |
# File 'lib/gitlab/qa/docker/command.rb', line 45 def mask_secrets @mask_secrets.each_with_object(to_s) { |secret, s| s.gsub!(secret, '*****') } end |
#name(identity) ⇒ Object
26 27 28 |
# File 'lib/gitlab/qa/docker/command.rb', line 26 def name(identity) tap { @args.push("--name #{identity}") } end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/gitlab/qa/docker/command.rb', line 34 def to_s "docker #{@args.join(' ')}" end |
#volume(from, to, opt = :z) ⇒ Object
22 23 24 |
# File 'lib/gitlab/qa/docker/command.rb', line 22 def volume(from, to, opt = :z) tap { @args.push("--volume #{from}:#{to}:#{opt}") } end |