awes_cli 0.0.22 → 0.0.23

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: ed029c05bdeaa99e0163aa5c2e87d9666e24b6007f1b1ce583a24dab8ba695bd
4
- data.tar.gz: 7fce07a3fe1255d784255844bd4b7476fb57c2e36dab632a703ff99ba12efdc2
3
+ metadata.gz: 7c56c2fd31133f9f9099a96c29b891f1cf30e206b9c4c5380e15d434037b2d9e
4
+ data.tar.gz: e87b7f33e19820c970ea30217cbf5d0e0e972b8428b76bcd2eeb81f572e9f1cc
5
5
  SHA512:
6
- metadata.gz: 3f444a6751fda720334e53a5bba33a394fbbccc55686fbdd9ebe4b6d174fca3d6a4b07efd38183f691f281ea90a60ff93194cd699efd13baf1d1c481b67f0113
7
- data.tar.gz: 9044707bcab97af14587cdd8e4bf996bfae89ab2769c042891afd4f4f5cd5488cecc17fb7681339840501ce6e3fabc81511667c332bfb3a37fc5fcd4587c3779
6
+ metadata.gz: 31091850270124ce71745f6c5b56e93329a668c2135c1a2c2b5fbd4fdd49de76904746e5247d3e9771d5a13de8011cb2c24c6e1f2833e3d82683eddc59523c79
7
+ data.tar.gz: 3c6c403da51706902d567c2f000912573c4fb07188bec6d3c61490d4059ea6468552dae6e5388c505daca3994f996044228b2f414b08ed401d241ee8df5a5db2
data/lib/deploy_app.rb CHANGED
@@ -2,12 +2,17 @@
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
11
  gcr_url = "asia.gcr.io/#{options[:project_id]}/#{options[:image_repo] || options[:app_name]}"
10
12
 
13
+ self.workload_hash = fetch_worload_yaml(options[:app_name], options[:namespace])
14
+ throw "Workload does not exists name: #{option[:app_name]} namespace: #{option[:namespace]}" if workload_hash.nil?
15
+
11
16
  if(!options[:image_tag].nil?)
12
17
  image_url = validate_image_tag_exists?(gcr_url, options[:image_tag])
13
18
  else
@@ -130,10 +135,17 @@ class DeployApp
130
135
  )
131
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.22
4
+ version: 0.0.23
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-06-03 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