awes_cli 0.0.3 → 0.0.9

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 +25 -5
  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: 912c0b612f6528b10417d66d062b3646f0526552c95af03c0d084a1f6f814256
4
+ data.tar.gz: 1932373450158a805b021a178067e1ec36163d64bf0675f90929eb7dd7ba44f7
5
5
  SHA512:
6
- metadata.gz: 0db247d4a41884ad6b4330095bd4e551271093d381f12be4bbb076fdf3d99e68d2b0db05f3cd2d1dfdd563a6e9a319499e16bedebbf01b8234123c788b066abb
7
- data.tar.gz: 29382c82bb3bdf13dd388d8553abaafc39e6ca1ea07946ad3447df36a6db26bcadde2199157a82d0ea449ee74ac02a028f416832042356fcf378d20088965a7d
6
+ metadata.gz: 48e7098342c9676b5b7e37f95622925835b4f076b823363433912eadc7312356efc4592275c8120f5794ca525d681e1ab3711b3819f970ee59c6fdf82bddb38c
7
+ data.tar.gz: 353e9d9422aab3511da8f2c0492ea1386edc2dfa5cc0de08b4a182cc4cf51cfa789d4a94a91bf497f21f24097a932187e2f320bf6e1b507ffee625b3bfe233a5
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
 
@@ -146,12 +162,16 @@ class DeployConfig
146
162
 
147
163
  gcr_url = "gcr.io/#{options[:project_id]}/#{options[:app_name]}"
148
164
 
149
- opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
165
+ # opt_image_url = options[:image_tag] && "#{gcr_url}:#{options[:image_tag]}"
150
166
 
151
- image_url = opt_image_url || spec[:image] || "#{gcr_url}:current"
152
- validate_image_tag_exists?(image_url)
167
+ # image_url = opt_image_url || spec[:image] || "#{gcr_url}:current"
168
+ image_url = "#{gcr_url}:current"
169
+
170
+ if !validate_image_tag_exists?(image_url)
171
+ build_image(image_url, gcr_url, options)
172
+ end
153
173
 
154
- yaml_file['$IMAGE_URL'] = image_url
174
+ yaml_file.gsub!(/\$IMAGE_URL/, image_url)
155
175
 
156
176
  FileUtils.mkdir_p('./tmp')
157
177
 
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.9
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-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ather cli tool
14
14
  email: umar.siddiqui@atherenergy.com