awes_cli 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/deploy_config.rb +21 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4cc4d6de38342a017745670bef1ed20995601a5450981b425555e57a017e9d0
4
- data.tar.gz: a5b5540d5d2f9cb6c1a277b78037e35853c346557a60447d256691373ea2ad4f
3
+ metadata.gz: b72f73478620b53b20cb928c317b045af6cb29fa54052b9d5a8d7e3fc9363e43
4
+ data.tar.gz: 67afc453ad192bd671ed0432095992cf65bc865329819961983f3942ecdf0e73
5
5
  SHA512:
6
- metadata.gz: 0db247d4a41884ad6b4330095bd4e551271093d381f12be4bbb076fdf3d99e68d2b0db05f3cd2d1dfdd563a6e9a319499e16bedebbf01b8234123c788b066abb
7
- data.tar.gz: 29382c82bb3bdf13dd388d8553abaafc39e6ca1ea07946ad3447df36a6db26bcadde2199157a82d0ea449ee74ac02a028f416832042356fcf378d20088965a7d
6
+ metadata.gz: d43cd9ab7326927042cbcdb6bd000b24f38c0ff2561e2cb006e2a32b34bdf515a9c72640c2ade40ec97f68f74ef2cea9003e02bf34c98800503425d8eea21228
7
+ data.tar.gz: b4533486ec19c1acd89cca1fe641daec2bb8d0ed701c2b030b57a8982d011b3f808fbe888dce26826784f4ef05cec46d619896d59df235b629de8f2b158af3e1
data/lib/deploy_config.rb CHANGED
@@ -119,7 +119,23 @@ class DeployConfig
119
119
  end
120
120
 
121
121
  def validate_image_tag_exists?(image_url)
122
- shell_cmd("gcloud container images describe #{image_url}")
122
+ system("gcloud container images describe #{image_url}")
123
+ end
124
+
125
+ def build_image(image_url, gcr_url, options)
126
+ commit_image_tag = ENV['CI_COMMIT_SHORT_SHA'] || `git rev-parse --short HEAD`
127
+ time_image_tag=`TZ=IST-5:30 date +'%Y.%m.%d.%HH.%MM.%SS'`
128
+ commit_image_url = "#{gcr_url}:#{commit_image_tag}".strip
129
+ time_image_url = "#{gcr_url}:#{time_image_tag}".strip
130
+
131
+ project_id = options[:project_id]
132
+
133
+ shell_cmd("gcloud builds submit --project #{project_id} --timeout=20m --tag #{time_image_url} || true")
134
+
135
+ shell_cmd("gcloud container images add-tag --quiet #{time_image_url} #{commit_image_url}")
136
+
137
+ shell_cmd("gcloud container images add-tag --quiet #{time_image_url} #{image_url}")
138
+
123
139
  image_url
124
140
  end
125
141
 
@@ -149,7 +165,10 @@ class DeployConfig
149
165
  opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
150
166
 
151
167
  image_url = opt_image_url || spec[:image] || "#{gcr_url}:current"
152
- validate_image_tag_exists?(image_url)
168
+
169
+ if !validate_image_tag_exists?(image_url)
170
+ build_image(image_url, gcr_url, options)
171
+ end
153
172
 
154
173
  yaml_file['$IMAGE_URL'] = image_url
155
174
 
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.3
4
+ version: 0.0.4
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-07-23 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ather cli tool
14
14
  email: umar.siddiqui@atherenergy.com