awes_cli 0.0.19 → 0.0.20.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f0e4777e83a45e05f52d29479aa33d890d6a8b8dad004337d7a4c8d802ef743
4
- data.tar.gz: b3bfa5071c3ef1ad26a3d86032457947f7b69e3d75deb5867a1c912fc6040949
3
+ metadata.gz: 317d18d4cd0256b047d9bf1df3ada8ad5fbaf0729f977fa0814a0eb3ff333bd2
4
+ data.tar.gz: 0c4ef3b7d8091e32a47e1da30f053332a30b9086c9ee8a9a432517509c161b10
5
5
  SHA512:
6
- metadata.gz: d69f49f2f7a195f7032e0d22ecc5ffb8950f68f653e304bd1ac7695f8bdfbeed03f6c2c125199c895b72cb8d1890a7196df6292bfec31615816ab629c7ee00ff
7
- data.tar.gz: 94cd29995c702077d47cdb48d9682e281c4d44dde94fd0cfa318fa4e661535fe9811372163b73381e8736b3df6cd9d0acc54cc3b0b7bfdd5fa3790f5b2c05283
6
+ metadata.gz: 593e57a190e46a214bddf11396638c45d4f334675a2c55a33f31d19b7a077fe8412270b38d5cb117d75e2ab1ca996a815d52bf161539262ef05b04392f86cc5c
7
+ data.tar.gz: 78f9aff161a12632079d62cd6c690af2744b245e77598b4930cec6fffc81f03b9edeeec133032c3d15933d37b01dd91358704521c1416a38a12eb27f3f624bc0
@@ -5,7 +5,7 @@ class BuildAppImage
5
5
  def main
6
6
  options = get_options
7
7
 
8
- gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo]}"
8
+ gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo]}"
9
9
 
10
10
  image_url = build_image(gcr_url, options)
11
11
  end
data/lib/deploy_app.rb CHANGED
@@ -2,11 +2,13 @@
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)
8
10
 
9
- gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
11
+ gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
10
12
 
11
13
  if(!options[:image_tag].nil?)
12
14
  image_url = validate_image_tag_exists?(gcr_url, options[:image_tag])
@@ -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
+
132
136
  app_name = options[:app_name]
133
- shell_cmd("kubectl set image deployment #{app_name} #{app_name}=#{image_url} -n #{options[:namespace]}")
137
+ shell_cmd("kubectl set image #{workload_hash['kind']} #{app_name} #{app_name}=#{image_url} -n #{options[:namespace]}")
134
138
 
135
- shell_cmd("kubectl rollout status deployment/#{app_name} -n #{options[:namespace]}")
139
+ shell_cmd("kubectl rollout status #{workload_hash['kind']} #{app_name} -n #{options[:namespace]}")
136
140
 
137
141
  shell_cmd("gcloud container images add-tag --quiet #{image_url} #{gcr_url}:current")
138
142
  end
143
+
144
+ def fetch_worload_yaml(app_name, namespace)
145
+ json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
146
+ return JSON.parse(json_deploy) if(json_deploy != "")
147
+ json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
148
+ return JSON.parse(json_statefulset) if(json_statefulset != "")
149
+ throw "Workload does not exists name: #{app_name} namespace: #{namespace}"
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,12 +164,12 @@ 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"
169
- # image_url = spec[:image] if spec[:image].empty? && validate_image_tag_exists?(spec[:image])
170
- # image_url = opt_image_url if validate_image_tag_exists?(opt_image_url)
171
+ image_url = spec[:image] if validate_image_tag_exists?(spec[:image])
172
+ image_url = opt_image_url if validate_image_tag_exists?(opt_image_url)
171
173
 
172
174
  if !validate_image_tag_exists?(image_url)
173
175
  build_image(image_url, gcr_url, options)
@@ -183,7 +185,9 @@ class DeployConfig
183
185
 
184
186
  shell_cmd("kubectl apply -f ./tmp/final.yaml")
185
187
 
186
- shell_cmd("kubectl rollout status deployment/#{options[:app_name]} -n #{options[:namespace]}")
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,7 @@ class DeployConfig
215
219
  end
216
220
 
217
221
  def app_container_spec(app_name, namespace)
218
- deploy_containers = `kubectl get deployment -n #{namespace} #{app_name} --output=jsonpath={.spec.template.spec.containers}`
222
+ deploy_containers = `kubectl get #{workload_hash['kind']} -n #{namespace} #{app_name} --output=jsonpath={.spec.template.spec.containers}`
219
223
  return nil if deploy_containers == ''
220
224
  JSON.parse(deploy_containers, symbolize_names: true).find { |container| container[:name] == app_name }
221
225
  end
@@ -229,4 +233,11 @@ class DeployConfig
229
233
 
230
234
  env_export_cmd
231
235
  end
236
+
237
+ def fetch_worload_yaml(app_name, namespace)
238
+ json_deploy = `kubectl get deployment -n #{namespace} #{app_name} -o json`
239
+ return JSON.parse(json_deploy) if(json_deploy != "")
240
+ json_statefulset = `kubectl get statefulset -n #{namespace} #{app_name} -o json`
241
+ return JSON.parse(json_statefulset) if(json_statefulset != "")
242
+ end
232
243
  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.19
4
+ version: 0.0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Umar Siddiqui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ather cli tool
14
14
  email: umar.siddiqui@atherenergy.com