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.
9 10 11 12 13 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 9 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.
6 7 8 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 6 def container @container end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 6 def namespace @namespace end |
#pod ⇒ Object (readonly)
Returns the value of attribute pod.
6 7 8 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 6 def pod @pod end |
Instance Method Details
#execute(command, stdin: true, tty: true) ⇒ Object
15 16 17 18 19 |
# File 'lib/train-kubernetes/kubectl_client.rb', line 15 def execute(command, stdin: true, tty: true) instruction = build_instruction(command, stdin, tty) shell = Mixlib::ShellOut.new(instruction) shell.run_command end |