awes_cli 0.0.22 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/deploy_app.rb +14 -2
- data/lib/deploy_config.rb +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45de21aa2807bd1e0d36671b120836b878a3fc3637b87020b65c3a24ef25213
|
4
|
+
data.tar.gz: 5a7952c65198f19e96412253c8a03e75cde414aedfdaa455227f2740c72645de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b4b1c840286cd11ca5c658f28a3388a811de313f40b98c640360116ecd46f07209aa45954cd9aac1e2ede841dba4e6e3d9ec286473c9235804d9ee0ff3636b
|
7
|
+
data.tar.gz: 9927493efbc0938dff1d43c1dc3f994f6ab24077406f0cdd6ede2c6b9436035494f53c15c468149cff0fcb1edb3650bd9d23f56d8826fa65a30eaa678c672527
|
data/lib/deploy_app.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
class DeployApp
|
5
|
+
attr_accessor :workload_hash
|
6
|
+
|
5
7
|
def main
|
6
8
|
options = get_options
|
7
9
|
take_approval(options)
|
@@ -129,11 +131,21 @@ class DeployApp
|
|
129
131
|
"--project #{options[:project_id]} "
|
130
132
|
)
|
131
133
|
|
134
|
+
self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
|
135
|
+
throw "Workload does not exists name: #{options[:app_name]} namespace: #{options[:namespace]}" if workload_hash.nil?
|
136
|
+
|
132
137
|
app_name = options[:app_name]
|
133
|
-
shell_cmd("kubectl set image
|
138
|
+
shell_cmd("kubectl set image #{workload_hash['kind']} #{app_name} #{app_name}=#{image_url} -n #{options[:namespace]}")
|
134
139
|
|
135
|
-
shell_cmd("kubectl rollout status
|
140
|
+
shell_cmd("kubectl rollout status #{workload_hash['kind']} #{app_name} -n #{options[:namespace]}")
|
136
141
|
|
137
142
|
shell_cmd("gcloud container images add-tag --quiet #{image_url} #{gcr_url}:current")
|
138
143
|
end
|
144
|
+
|
145
|
+
def fetch_worload_yaml(app_name, namespace)
|
146
|
+
json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
|
147
|
+
return JSON.parse(json_deploy) if(json_deploy != "")
|
148
|
+
json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
|
149
|
+
return JSON.parse(json_statefulset) if(json_statefulset != "")
|
150
|
+
end
|
139
151
|
end
|
data/lib/deploy_config.rb
CHANGED
@@ -6,6 +6,8 @@ require 'yaml'
|
|
6
6
|
require 'fileutils'
|
7
7
|
|
8
8
|
class DeployConfig
|
9
|
+
attr_accessor :workload_hash
|
10
|
+
|
9
11
|
def main
|
10
12
|
options = get_options
|
11
13
|
|
@@ -162,7 +164,7 @@ class DeployConfig
|
|
162
164
|
yaml_file.gsub!(/\$#{env_key}\s*$/, "'#{env_val}'")
|
163
165
|
end
|
164
166
|
|
165
|
-
gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
167
|
+
gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
|
166
168
|
opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
|
167
169
|
|
168
170
|
image_url = "#{gcr_url}:current"
|
@@ -183,7 +185,9 @@ class DeployConfig
|
|
183
185
|
|
184
186
|
shell_cmd("kubectl apply -f ./tmp/final.yaml")
|
185
187
|
|
186
|
-
|
188
|
+
self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
|
189
|
+
|
190
|
+
shell_cmd("kubectl rollout status #{workload_hash['kind']}/#{options[:app_name]} -n #{options[:namespace]}")
|
187
191
|
end
|
188
192
|
|
189
193
|
def override_envs(options)
|
@@ -215,7 +219,8 @@ class DeployConfig
|
|
215
219
|
end
|
216
220
|
|
217
221
|
def app_container_spec(app_name, namespace)
|
218
|
-
|
222
|
+
return nil if workload_hash.nil?
|
223
|
+
deploy_containers = `kubectl get #{workload_hash['kind']} -n #{namespace} #{app_name} --output=jsonpath={.spec.template.spec.containers}`
|
219
224
|
return nil if deploy_containers == ''
|
220
225
|
JSON.parse(deploy_containers, symbolize_names: true).find { |container| container[:name] == app_name }
|
221
226
|
end
|
@@ -229,4 +234,11 @@ class DeployConfig
|
|
229
234
|
|
230
235
|
env_export_cmd
|
231
236
|
end
|
237
|
+
|
238
|
+
def fetch_worload_yaml(app_name, namespace)
|
239
|
+
json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
|
240
|
+
return JSON.parse(json_deploy) if(json_deploy != "")
|
241
|
+
json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
|
242
|
+
return JSON.parse(json_statefulset) if(json_statefulset != "")
|
243
|
+
end
|
232
244
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awes_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umar Siddiqui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ather cli tool
|
14
14
|
email: umar.siddiqui@atherenergy.com
|