awes_cli 0.0.20 → 0.0.20.3

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: 07d9a40c44ff5c9a526f11ccb81904f1c0aced7104e5c9dc8a9ab769b617f3e4
4
- data.tar.gz: a252d265db0554441789cf17419d31711f5fdaf9af3507c18c67cfdad35ba4a7
3
+ metadata.gz: d2f0c454abcbc8dfa7d838ddf2a3e192f0eb550ac5162a68a3ff4a54ecdc5768
4
+ data.tar.gz: 8345bc37c27f70320f109219272849d0a51cee4d8df3b66d44fba871c01d70c2
5
5
  SHA512:
6
- metadata.gz: ccdad37a9e690310553f3921b80f9145655ead217ce68b125a98a8d2ed8dbc918aaef27ab55e1276ca594bfdbdced4d046a227369934cf01e215d9a3ec098553
7
- data.tar.gz: 5d32cc7d8c0e88d1cf19805238c2c325541b3ea5fc15f04a7826d80c2d8f8069d22b20ceda44d410511a56a3d608a6ee9e1fa7d4e57af177d72572ff8186ad2a
6
+ metadata.gz: 7fc3e5003cde68db1f8c8a96cbf470003ad9f3d3d281cc5c006aae8eb7e19bff0bc4fafaeb237dde2561228e8cb39c6a23196a8ab12b72bb27a374f360e9c054
7
+ data.tar.gz: a1132bee963af57ba68494b79c21c10afa4f303e6bac92de38646ea49807fc60c76be62e100779170ce863f57a0d7d93f426f705638b8ba95ab435d5c9ef2661
@@ -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,11 +164,11 @@ 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])
171
+ image_url = spec[:image] if validate_image_tag_exists?(spec[:image])
170
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)
@@ -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,8 @@ 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
+ 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.20
4
+ version: 0.0.20.3
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