Class: Docker::API::ExecResult
- Inherits:
-
Struct
- Object
- Struct
- Docker::API::ExecResult
- Defined in:
- lib/docker/api/resources/exec.rb
Overview
What a command run inside a container produced.
A non-zero #exit_code is returned rather than raised. Whether a failing command is an error depends entirely on why it was run -- a test runner expects failures, a provisioning step does not -- so the decision belongs to the caller. #success? and #check! are there for the common cases.
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
Returns the value of attribute exit_code.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #check! ⇒ self
-
#output ⇒ String
Stdout and stderr in the order they were produced.
-
#success? ⇒ Boolean
Nil is not success.
Instance Attribute Details
#exit_code ⇒ Object
Returns the value of attribute exit_code
14 15 16 |
# File 'lib/docker/api/resources/exec.rb', line 14 def exit_code @exit_code end |
#stderr ⇒ Object
Returns the value of attribute stderr
14 15 16 |
# File 'lib/docker/api/resources/exec.rb', line 14 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout
14 15 16 |
# File 'lib/docker/api/resources/exec.rb', line 14 def stdout @stdout end |
Instance Method Details
#check! ⇒ self
27 28 29 30 31 |
# File 'lib/docker/api/resources/exec.rb', line 27 def check! return self if success? raise Error.new(, operation: "exec") end |
#output ⇒ String
Returns stdout and stderr in the order they were produced.
34 35 36 |
# File 'lib/docker/api/resources/exec.rb', line 34 def output "#{stdout}#{stderr}" end |
#success? ⇒ Boolean
Nil is not success. The daemon reports a null exit code while an exec is still being reaped, and treating that as zero fails open on exactly the question this struct exists to answer.
20 21 22 |
# File 'lib/docker/api/resources/exec.rb', line 20 def success? exit_code == 0 end |