Class: Kubecontrol::Pod
- Inherits:
-
Object
- Object
- Kubecontrol::Pod
- Defined in:
- lib/kubecontrol/pod.rb
Constant Summary collapse
- RESOURCE_NAME =
'pods'.freeze
- RUNNING =
'Running'.freeze
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#ready ⇒ Object
readonly
Returns the value of attribute ready.
-
#restarts ⇒ Object
readonly
Returns the value of attribute restarts.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #exec(command) ⇒ Object
-
#initialize(name, ready, status, restarts, age, namespace, client) ⇒ Pod
constructor
A new instance of Pod.
- #ready? ⇒ Boolean
- #running? ⇒ Boolean
- #stopped? ⇒ Boolean
Constructor Details
#initialize(name, ready, status, restarts, age, namespace, client) ⇒ Pod
Returns a new instance of Pod.
8 9 10 11 12 13 14 15 16 |
# File 'lib/kubecontrol/pod.rb', line 8 def initialize(name, ready, status, restarts, age, namespace, client) @name = name @ready = ready @status = status @restarts = restarts @age = age @namespace = namespace @client = client end |
Instance Attribute Details
#age ⇒ Object (readonly)
Returns the value of attribute age.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def age @age end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def namespace @namespace end |
#ready ⇒ Object (readonly)
Returns the value of attribute ready.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def ready @ready end |
#restarts ⇒ Object (readonly)
Returns the value of attribute restarts.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def restarts @restarts end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/kubecontrol/pod.rb', line 6 def status @status end |
Instance Method Details
#exec(command) ⇒ Object
31 32 33 |
# File 'lib/kubecontrol/pod.rb', line 31 def exec(command) @client.kubectl_command("exec -i #{name} -- sh -c \"#{command.gsub('"', '\"')}\"") end |
#ready? ⇒ Boolean
26 27 28 29 |
# File 'lib/kubecontrol/pod.rb', line 26 def ready? pod_containers = @ready.split('/').last @ready == "#{pod_containers}/#{pod_containers}" end |
#running? ⇒ Boolean
22 23 24 |
# File 'lib/kubecontrol/pod.rb', line 22 def running? @status == RUNNING end |
#stopped? ⇒ Boolean
18 19 20 |
# File 'lib/kubecontrol/pod.rb', line 18 def stopped? @status != RUNNING end |