Class: Kubes::Kubectl::Fetch::Deployment
- Inherits:
-
Base
- Object
- Base
- Kubes::Kubectl::Fetch::Deployment
show all
- Extended by:
- Memoist
- Defined in:
- lib/kubes/kubectl/fetch/deployment.rb
Instance Method Summary
collapse
Methods inherited from Base
#fetch, #initialize, #namespace
Methods included from Util::Sh
#sh, #sh_capture
Methods included from Logging
#logger
Instance Method Details
#deployment ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/kubes/kubectl/fetch/deployment.rb', line 13
def deployment
items = fetch(:deployment)
deployments = items.select { |i| i['kind'] == "Deployment" }
if !@options[:deployment] && !@options[:pod] && deployments.size > 1
names = deployments.map { |d| d['metadata']['name'] }
logger.info <<~EOL
INFO: More than one deployment found.
Deployment names: #{names.join(', ')}
Using #{names.first}
Note: You can specify the deployment to use with --deployment or -d
EOL
end
find_deployment(deployments)
end
|
#find_deployment(deployments) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/kubes/kubectl/fetch/deployment.rb', line 36
def find_deployment(deployments)
if @options[:deployment]
deployments.find { |d| d['metadata']['name'] == @options[:deployment] }
else
deployments.first
end
end
|
#found ⇒ Object
32
33
34
|
# File 'lib/kubes/kubectl/fetch/deployment.rb', line 32
def found
!!deployment
end
|
5
6
7
|
# File 'lib/kubes/kubectl/fetch/deployment.rb', line 5
def metadata
deployment['metadata'] if found
end
|
#spec ⇒ Object
9
10
11
|
# File 'lib/kubes/kubectl/fetch/deployment.rb', line 9
def spec
deployment['spec'] if found
end
|