awes_cli 0.0.18 → 0.0.20.1

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: 10a566d2c52ff44e309b871cdfda5e5d172e01dc9c1a4dd8e140e3e1e927a8f4
4
- data.tar.gz: 81cb67293661d535c3cc72fff5948302439f72227cddb288e6d1bad575518498
3
+ metadata.gz: 3275174a80e5f3d18a32e2769363accdb03b48f536cf8d3d7996a0685749db23
4
+ data.tar.gz: ce31d146d9cbae8e71d5f804ead89707b9100f92cf3bcb4c694c1c19a4587257
5
5
  SHA512:
6
- metadata.gz: 52263ac435526d209fea687e89ea715c701f507c0f4a2b1cc85b33d29a07403282e9f210b2f10c1ebd61f0f45e6e5c84fbd029d28594a0a0f342ab01cb8015e7
7
- data.tar.gz: c585924910e12638a93bfc8302afb2abd2373daca6e8a3004a05c5f65b8139c11f07187c81f2ea04f3fc3ff7fe1315449f39baa855bb3c14a13e502aa8142c4e
6
+ metadata.gz: bc2acf535f5e01c844584be94b967e0936a420ab5b0094b025904d8c6cf58fc32caeac7b0e6b10df1477068a33a9d2ce2b804bad4c99bb2ce0d40484d8d0fda1
7
+ data.tar.gz: 7047d21562e67412e82e3dbb424ee840f73e024af7eaecc34b58154d74f6a94eb495d71ea85105da318322815a5bc1e52375ad6bfc0670a35aa6b89ea6da6ed9
@@ -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 "
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
 
@@ -148,6 +150,8 @@ class DeployConfig
148
150
  "--project #{options[:project_id]} "
149
151
  )
150
152
 
153
+ self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
154
+
151
155
  spec = app_container_spec(options[:app_name], options[:namespace]) || {}
152
156
 
153
157
  override_envs = override_envs(options)
@@ -162,11 +166,11 @@ class DeployConfig
162
166
  yaml_file.gsub!(/\$#{env_key}\s*$/, "'#{env_val}'")
163
167
  end
164
168
 
165
- gcr_url = "gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
169
+ gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
166
170
  opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
167
171
 
168
172
  image_url = "#{gcr_url}:current"
169
- # image_url = spec[:image] if spec[:image].empty? && validate_image_tag_exists?(spec[:image])
173
+ image_url = spec[:image] if validate_image_tag_exists?(spec[:image])
170
174
  image_url = opt_image_url if validate_image_tag_exists?(opt_image_url)
171
175
 
172
176
  if !validate_image_tag_exists?(image_url)
@@ -183,7 +187,7 @@ class DeployConfig
183
187
 
184
188
  shell_cmd("kubectl apply -f ./tmp/final.yaml")
185
189
 
186
- shell_cmd("kubectl rollout status deployment/#{options[:app_name]} -n #{options[:namespace]}")
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.18
4
+ version: 0.0.20.1
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