Class: KubeclientExec::Execute::Executor
- Inherits:
-
Object
- Object
- KubeclientExec::Execute::Executor
- Defined in:
- lib/kubeclient_exec/execute/executor.rb
Constant Summary collapse
- EXEC_STDIN =
0
- EXEC_STDOUT =
1
- EXEC_STDERR =
2
- EXEC_DCKERR =
Seems like this is used for docker errors
3
Instance Attribute Summary collapse
-
#last_command ⇒ Object
readonly
Returns the value of attribute last_command.
-
#last_stderr ⇒ Object
readonly
Returns the value of attribute last_stderr.
-
#last_stdout ⇒ Object
readonly
Returns the value of attribute last_stdout.
Instance Method Summary collapse
- #done? ⇒ Boolean
- #execute(command) ⇒ Object
-
#initialize(command, url, kubeclient_options, options, &block) ⇒ Executor
constructor
A new instance of Executor.
- #on_close(&block) ⇒ Object
- #on_stderr(&block) ⇒ Object
- #on_stdout(&block) ⇒ Object
- #ready_state ⇒ Object
- #stop ⇒ Object
- #stop! ⇒ Object
- #write(content) ⇒ Object
Constructor Details
#initialize(command, url, kubeclient_options, options, &block) ⇒ Executor
Returns a new instance of Executor.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 15 def initialize(command, url, , , &block) @last_command = command @url = url @kubeclient_options = @options = @on_open = block @suppress_errors = [:suppress_errors] if [:mode] == :adhoc @on_stdout = ->(_) { stop } @on_stderr = ->(_) { stop } end setup end |
Instance Attribute Details
#last_command ⇒ Object (readonly)
Returns the value of attribute last_command.
13 14 15 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 13 def last_command @last_command end |
#last_stderr ⇒ Object (readonly)
Returns the value of attribute last_stderr.
13 14 15 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 13 def last_stderr @last_stderr end |
#last_stdout ⇒ Object (readonly)
Returns the value of attribute last_stdout.
13 14 15 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 13 def last_stdout @last_stdout end |
Instance Method Details
#done? ⇒ Boolean
67 68 69 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 67 def done? @ws.instance_variable_get(:@driver).instance_variable_get(:@queue).empty? end |
#execute(command) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 31 def execute(command) raise 'ws not initialized' unless @ws @last_command = command @ws.send((command + "\n").unpack("C*").unshift(EXEC_STDIN)) end |
#on_close(&block) ⇒ Object
53 54 55 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 53 def on_close(&block) @on_close = block end |
#on_stderr(&block) ⇒ Object
49 50 51 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 49 def on_stderr(&block) @on_stderr = block end |
#on_stdout(&block) ⇒ Object
45 46 47 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 45 def on_stdout(&block) @on_stdout = block end |
#ready_state ⇒ Object
71 72 73 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 71 def ready_state @ws.ready_state end |
#stop ⇒ Object
57 58 59 60 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 57 def stop @ws.instance_variable_get(:@stream).close_connection_after_writing @on_close.call if @on_close end |
#stop! ⇒ Object
62 63 64 65 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 62 def stop! stop EM.stop_event_loop end |
#write(content) ⇒ Object
39 40 41 42 43 |
# File 'lib/kubeclient_exec/execute/executor.rb', line 39 def write(content) raise 'ws not initialized' unless @ws @ws.send(content.unpack("C*").unshift(EXEC_STDIN)) end |