awes_cli 0.0.21 → 0.0.24

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: e2a2d43790a65fec3fbf577af45029ac11fda9db4032e7c638d59d2fb6bc5937
4
- data.tar.gz: f3cba1e770612436ecbf28a521ae5c40137b7d57c1100de52a7263b4e0510308
3
+ metadata.gz: f7841dbd0b1f58797c766eb6d4f594be7fc48d82db4dd45af2289e6db76fc6f8
4
+ data.tar.gz: 7945aa2ee989d87bcbf0fae9dd805bca650b96c44d55613af125b74bc030d67b
5
5
  SHA512:
6
- metadata.gz: d387c3da479c1aed33d6cd3b04843df32c5adefe7c0d087e5ce61888da9c79cdd90ddcf6c0d6b58d243e371b864184e0ff716c1b91cbf24f0c889863d2ff0c5c
7
- data.tar.gz: 21952628ca8a2b25fbfc17be51ef5c204096c67e6a8f3ccc3411b1f710f4906923929ace17b3c5bebe2140408727fd96ccffbe65465f2ec6ed8a93ecd64985e7
6
+ metadata.gz: 9b983f65a6a2e93f5b1772b7eee2c5717a31ce0cbdf260e3ef06735510707e2b566b0d868fc2770347beef78f0aa700993e22ff770576b97e628f4d90f0d2df0
7
+ data.tar.gz: 68d2f56049b52715de0c20f204ad224ade0b560db65fe65bb9b4e0ef6de80f9b73ca23f01d2d6212dd70706199c1487589b37ed8807f77eb1ea6759943edf34a
@@ -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
+ throw "Workload does not exists name: #{option[:app_name]} namespace: #{option[:namespace]}" if workload_hash.nil?
136
+
132
137
  app_name = options[:app_name]
133
- shell_cmd("kubectl set image deployment #{app_name} #{app_name}=#{image_url} -n #{options[:namespace]}")
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 deployment/#{app_name} -n #{options[:namespace]}")
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
- 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.21
4
+ version: 0.0.24
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