Class: TrainPlugins::TrainKubernetes::KubectlClient
- Inherits:
-
Object
- Object
- TrainPlugins::TrainKubernetes::KubectlClient
- Defined in:
- lib/train-kubernetes/kubectl_client.rb
Constant Summary collapse
- DEFAULT_NAMESPACE =
"default".freeze
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#pod ⇒ Object
readonly
Returns the value of attribute pod.
Instance Method Summary collapse
- #execute(command, stdin: true, tty: true) ⇒ Object
-
#initialize(pod:, namespace: nil, container: nil) ⇒ KubectlClient
constructor
A new instance of KubectlClient.
Constructor Details
#initialize(pod:, namespace: nil, container: nil) ⇒ KubectlClient
Returns a new instance of KubectlClient.
11 12 13 14 15 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 11 def initialize(pod:, namespace: nil, container: nil) @pod = pod @container = container @namespace = namespace || DEFAULT_NAMESPACE end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
7 8 9 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 7 def container @container end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 7 def namespace @namespace end |
#pod ⇒ Object (readonly)
Returns the value of attribute pod.
7 8 9 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 7 def pod @pod end |
Instance Method Details
#execute(command, stdin: true, tty: true) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 17 def execute(command, stdin: true, tty: true) instruction = build_instruction(command, stdin, tty) shell = Mixlib::ShellOut.new(instruction) res = shell.run_command Train::Extras::CommandResult.new(res.stdout, res.stderr, res.exitstatus) rescue Errno::ENOENT => _e Train::Extras::CommandResult.new("", "", 1) end |