prima-twig 1.3.2 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twig-feature +156 -160
- data/bin/twig-update-ami +2 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a95ae976ed363de270085df7243c4eb91ed3a081a19e4e695f252ce15666bec4
|
4
|
+
data.tar.gz: de8d04ef78a19770304483698c220a28eb8336d16ef7a8a09906556629f0aee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2bcf8e5f627d36dbd8330342a9e4263d3a5ff193f76ef1a9ff93df4e90d0d81d484a1eb3496d14173b325619f77882607ed2b79c7f13b1426702afe38e5264
|
7
|
+
data.tar.gz: 9af61547c40b6d1b04446de8139451de9e406dc6e88e9cdb3801c6543a261722d17e00ca2dc3a3e45ba79aa6c089db3957ef3c16b604bb20bae70e03bba55a45
|
data/bin/twig-feature
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
-
require_relative '../lib/prima_twig
|
5
|
-
require_relative '../lib/prima_aws_client
|
4
|
+
require_relative '../lib/prima_twig'
|
5
|
+
require_relative '../lib/prima_aws_client'
|
6
6
|
require 'digest'
|
7
7
|
require 'json'
|
8
8
|
require 'launchy'
|
@@ -14,11 +14,11 @@ class Release
|
|
14
14
|
include Command
|
15
15
|
include PrimaAwsClient
|
16
16
|
|
17
|
-
def initialize(update_gem=true)
|
17
|
+
def initialize(update_gem = true)
|
18
18
|
@prima = Prima.new
|
19
19
|
if update_gem
|
20
20
|
output 'Controllo se ci sono aggiornamenti da fare (potrebbe richiedere qualche minuto)'
|
21
|
-
unless `gem update prima-twig
|
21
|
+
unless `gem update prima-twig` == "Updating installed gems\nNothing to update\n"
|
22
22
|
output 'Gemma prima-twig aggiornata'
|
23
23
|
exec "twig feature #{ARGV.join ' '}"
|
24
24
|
end
|
@@ -48,20 +48,23 @@ class Release
|
|
48
48
|
'vianello' => {},
|
49
49
|
'domus' => {},
|
50
50
|
'toretto' => {},
|
51
|
-
'lira' => {}
|
51
|
+
'lira' => {},
|
52
|
+
'frontale' => {},
|
53
|
+
'baggio' => {},
|
54
|
+
'mario' => {}
|
52
55
|
}
|
53
56
|
@base_stack_name_alb = 'ecs-alb-http-public-qa-'
|
54
57
|
@base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
|
55
58
|
@cloudflare = Rubyflare.connect_with(ENV['CLOUDFLARE_EMAIL'], ENV['CLOUDFLARE_APIKEY'])
|
56
59
|
@config = YAML.load_file 'twig.yml'
|
57
|
-
@gh = Octokit::Client.new(:
|
60
|
+
@gh = Octokit::Client.new(access_token: @config['github'])
|
58
61
|
end
|
59
62
|
|
60
63
|
def execute!(args)
|
61
64
|
case args[0]
|
62
65
|
when 'qainit'
|
63
|
-
abort('Non sei nella cartella di qainit') unless Dir.pwd.match
|
64
|
-
if [
|
66
|
+
abort('Non sei nella cartella di qainit') unless Dir.pwd.match('qainit$') || Dir.pwd.match('/drone/src')
|
67
|
+
if %w[terminate stop shutdown halt destroy].include? args[1]
|
65
68
|
qainit_deploy_shutdown!
|
66
69
|
elsif 'update' == args[1]
|
67
70
|
qainit_deploy_update!
|
@@ -76,13 +79,11 @@ class Release
|
|
76
79
|
when 'suite'
|
77
80
|
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$'
|
78
81
|
if 'deploy' == args[1]
|
79
|
-
suite_py_branches
|
82
|
+
suite_py_branches
|
80
83
|
qainit_deploy!(true)
|
81
84
|
end
|
82
85
|
when 'deploy'
|
83
|
-
if 'lock' == args[1]
|
84
|
-
deploy_lock!
|
85
|
-
end
|
86
|
+
deploy_lock! if 'lock' == args[1]
|
86
87
|
when 'aggregator'
|
87
88
|
if 'enable' == args[1]
|
88
89
|
aggregator_enable!
|
@@ -104,25 +105,25 @@ class Release
|
|
104
105
|
def aggregator_disable!
|
105
106
|
output 'Disable aggregator'
|
106
107
|
|
107
|
-
output
|
108
|
-
output
|
109
|
-
stack_list, envs = get_stacks
|
108
|
+
output 'Recupero le informazioni relative al puntamento dei record DNS...'
|
109
|
+
output 'Recupero le informazioni sui QA attivi...'
|
110
|
+
stack_list, envs = get_stacks
|
110
111
|
|
111
112
|
env_hash = nil
|
112
|
-
|
113
|
-
|
113
|
+
if envs.empty?
|
114
|
+
output 'Nessun QA trovato'.red
|
115
|
+
exit
|
116
|
+
else
|
117
|
+
env_hash = envs.detect do |_key, tags|
|
114
118
|
aggregator_enabled = tags.detect do |tag|
|
115
|
-
tag.key ===
|
119
|
+
tag.key === 'hostname_pattern_priority' and tag.value === '1'
|
116
120
|
end.is_a?(Aws::CloudFormation::Types::Tag)
|
117
121
|
aggregator_enabled
|
118
122
|
end[0]
|
119
|
-
dns_records = @cloudflare.get(
|
120
|
-
stop_if dns_records.body[:result].empty?,
|
121
|
-
change_hostname_priority(env_hash, hostname_pattern_priority
|
123
|
+
dns_records = @cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8]) })
|
124
|
+
stop_if dns_records.body[:result].empty?, 'I record DNS degli aggregatori non stanno puntando ad un QA'.red
|
125
|
+
change_hostname_priority(env_hash, hostname_pattern_priority)
|
122
126
|
dns_to_staging(env_hash)
|
123
|
-
else
|
124
|
-
output 'Nessun QA trovato'.red
|
125
|
-
exit
|
126
127
|
end
|
127
128
|
|
128
129
|
output 'Finito!'.green
|
@@ -135,46 +136,46 @@ class Release
|
|
135
136
|
dns_records = @cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: 'staging.prima.it' })
|
136
137
|
stop_if dns_records.body[:result].empty?, "I record DNS degli aggregatori stanno gia' puntando ad un QA".red
|
137
138
|
|
138
|
-
output
|
139
|
-
stack_list, envs = get_stacks
|
139
|
+
output 'Recupero le informazioni sui QA attivi...'
|
140
|
+
stack_list, envs = get_stacks
|
140
141
|
|
141
142
|
env_hash = nil
|
142
|
-
|
143
|
+
if envs.empty?
|
144
|
+
output 'Nessun QA trovato'.red
|
145
|
+
exit
|
146
|
+
else
|
143
147
|
env_hash = choose do |menu|
|
144
|
-
menu.prompt =
|
148
|
+
menu.prompt = 'Scegli il QA al quale vuoi far puntare gli ambienti di staging dei comparatori: '.cyan
|
145
149
|
menu.shell = true
|
146
150
|
envs.each do |key, env|
|
147
|
-
title =
|
151
|
+
title = ''
|
148
152
|
env.each do |e|
|
149
153
|
title << "\n#{e.key.upcase}: #{e.value}"
|
150
154
|
end
|
151
|
-
msg =
|
155
|
+
msg = @prima.reduce_size(title, 1000).to_s.light_blue
|
152
156
|
menu.choice(msg) { key }
|
153
157
|
end
|
154
158
|
end
|
155
|
-
else
|
156
|
-
output "Nessun QA trovato".red
|
157
|
-
exit
|
158
159
|
end
|
159
160
|
|
160
|
-
change_hostname_priority(env_hash,
|
161
|
+
change_hostname_priority(env_hash, '1')
|
161
162
|
|
162
163
|
dns_records.body[:result].each do |dns|
|
163
|
-
if dns[:name] =~ /^\w
|
164
|
+
if dns[:name] =~ /^\w+-\w+-staging\.prima\.it$/
|
164
165
|
output "Changing #{dns[:name]} DNS record"
|
165
|
-
@cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: get_alb_host(@base_stack_name_alb + env_hash[3..8]), proxied: true, ttl: 1})
|
166
|
+
@cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", { type: 'CNAME', name: dns[:name], content: get_alb_host(@base_stack_name_alb + env_hash[3..8]), proxied: true, ttl: 1 })
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
169
|
-
output
|
170
|
+
output 'Finito!'.green
|
170
171
|
end
|
171
172
|
|
172
173
|
def change_hostname_priority(env_hash, hostname_pattern_priority)
|
173
174
|
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
174
175
|
tags = get_stack_tags(cluster_stack_name).map do |tag|
|
175
|
-
if tag.key ===
|
176
|
+
if tag.key === 'hostname_pattern_priority'
|
176
177
|
{
|
177
|
-
key:
|
178
|
+
key: 'hostname_pattern_priority',
|
178
179
|
value: hostname_pattern_priority
|
179
180
|
}
|
180
181
|
else
|
@@ -199,14 +200,14 @@ class Release
|
|
199
200
|
|
200
201
|
stack_name_web = "ecs-task-web-#{env_hash}"
|
201
202
|
parameters = get_stack_parameters(stack_name_web).map do |param|
|
202
|
-
if param.parameter_key ===
|
203
|
+
if param.parameter_key === 'HostnamePatternPriority'
|
203
204
|
{
|
204
|
-
parameter_key:
|
205
|
+
parameter_key: 'HostnamePatternPriority',
|
205
206
|
parameter_value: hostname_pattern_priority
|
206
207
|
}
|
207
|
-
elsif param.parameter_key ===
|
208
|
+
elsif param.parameter_key === 'HostnamePatternAggregatorPriority'
|
208
209
|
{
|
209
|
-
parameter_key:
|
210
|
+
parameter_key: 'HostnamePatternAggregatorPriority',
|
210
211
|
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
211
212
|
}
|
212
213
|
else
|
@@ -220,22 +221,25 @@ class Release
|
|
220
221
|
end
|
221
222
|
|
222
223
|
def dns_to_staging(env_hash)
|
223
|
-
output
|
224
|
-
dns_records = @cloudflare.get(
|
224
|
+
output 'Recupero le informazioni relative al puntamento dei record DNS...'
|
225
|
+
dns_records = @cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8]) })
|
225
226
|
dns_records.body[:result].each do |dns|
|
226
|
-
if dns[:name] =~ /^\w
|
227
|
+
if dns[:name] =~ /^\w+-\w+-staging\.prima\.it$/
|
227
228
|
output "Changing #{dns[:name]} DNS record"
|
228
|
-
@cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: 'staging.prima.it', proxied: true, ttl: 1})
|
229
|
+
@cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", { type: 'CNAME', name: dns[:name], content: 'staging.prima.it', proxied: true, ttl: 1 })
|
229
230
|
end
|
230
231
|
end
|
231
232
|
end
|
232
233
|
|
233
234
|
def deploy_shutdown!
|
234
|
-
output
|
235
|
+
output 'Recupero le informazioni sui QA attivi...'
|
235
236
|
stack_list, envs = get_stacks
|
236
237
|
|
237
238
|
env_hash = nil
|
238
|
-
|
239
|
+
if envs.empty?
|
240
|
+
output 'Nessun environment trovato'.red
|
241
|
+
exit
|
242
|
+
else
|
239
243
|
env_hash = choose do |menu|
|
240
244
|
menu.prompt = "Scegli l'environment che vuoi spegnere: ".cyan
|
241
245
|
menu.shell = true
|
@@ -249,9 +253,6 @@ class Release
|
|
249
253
|
menu.choice(msg) { key }
|
250
254
|
end
|
251
255
|
end
|
252
|
-
else
|
253
|
-
output 'Nessun environment trovato'.red
|
254
|
-
exit
|
255
256
|
end
|
256
257
|
|
257
258
|
cluster_stack_name = nil
|
@@ -262,6 +263,7 @@ class Release
|
|
262
263
|
cluster_stack_name = stack.stack_name
|
263
264
|
else
|
264
265
|
break unless stack.stack_name.match(/#{env_hash}$/)
|
266
|
+
|
265
267
|
stacks_to_delete.push(stack.stack_name)
|
266
268
|
delete_stack(stack.stack_name)
|
267
269
|
end
|
@@ -270,138 +272,134 @@ class Release
|
|
270
272
|
|
271
273
|
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
272
274
|
aggregator_enabled = get_stack_tags(cluster_stack_name).detect do |tag|
|
273
|
-
tag.key ===
|
275
|
+
tag.key === 'hostname_pattern_priority' and tag.value === '1'
|
274
276
|
end.is_a?(Aws::CloudFormation::Types::Tag)
|
275
277
|
|
276
|
-
if aggregator_enabled
|
277
|
-
dns_to_staging(env_hash)
|
278
|
-
end
|
278
|
+
dns_to_staging(env_hash) if aggregator_enabled
|
279
279
|
|
280
280
|
# Se non ha finito di cancellare le altre non si puo' cancellare il cluster
|
281
|
-
output
|
281
|
+
output 'Attendo 10 secondi per poter eliminare il cluster ECS'
|
282
282
|
|
283
283
|
while stacks_to_delete.length > 0
|
284
284
|
sleep 13
|
285
285
|
stacks_to_delete.each do |stack_name|
|
286
|
-
stacks_to_delete
|
286
|
+
stacks_to_delete -= [stack_name] unless stack_exists?(stack_name)
|
287
287
|
end
|
288
|
-
output "Stack ancora attivi: #{stacks_to_delete.length
|
288
|
+
output "Stack ancora attivi: #{stacks_to_delete.length}. Attendo altri 10 secondi per eliminare il cluster ECS"
|
289
289
|
end
|
290
290
|
|
291
291
|
delete_stack(cluster_stack_name)
|
292
292
|
delete_stack(@base_stack_name_alb + env_hash[3..8])
|
293
293
|
delete_stack(@base_stack_name_alb_ws + env_hash[3..8])
|
294
|
-
output
|
294
|
+
output 'Finito!'.green
|
295
295
|
end
|
296
296
|
|
297
297
|
def deploy_lock!
|
298
|
-
output
|
298
|
+
output 'Deploy update menu'
|
299
299
|
`git pull`
|
300
300
|
|
301
|
-
output
|
302
|
-
stack_list, envs = get_clusters
|
301
|
+
output 'Recupero le informazioni sui QA attivi...'
|
302
|
+
stack_list, envs = get_clusters
|
303
303
|
|
304
304
|
env_hash = nil
|
305
|
-
|
305
|
+
if envs.empty?
|
306
|
+
output 'Nessun QA trovato'.red
|
307
|
+
exit
|
308
|
+
else
|
306
309
|
env_hash = choose do |menu|
|
307
|
-
menu.prompt =
|
310
|
+
menu.prompt = 'Scegli il QA che vuoi proteggere dallo spegnimento automatico: '.cyan
|
308
311
|
menu.shell = true
|
309
312
|
envs.each do |key, env|
|
310
|
-
title =
|
313
|
+
title = ''
|
311
314
|
env.each do |e|
|
312
|
-
title <<
|
315
|
+
title << e.value.to_s if e.key == 'qainit'
|
313
316
|
end
|
314
|
-
msg =
|
317
|
+
msg = @prima.reduce_size(title, 1000).to_s.light_blue
|
315
318
|
menu.choice(msg) { key }
|
316
319
|
end
|
317
320
|
end
|
318
|
-
else
|
319
|
-
output "Nessun QA trovato".red
|
320
|
-
exit
|
321
321
|
end
|
322
322
|
|
323
323
|
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
324
324
|
if stack_exists?(cluster_stack_name)
|
325
325
|
tags = get_stack_tags(cluster_stack_name)
|
326
|
-
tag_keep_data = Aws::CloudFormation::Types::Tag.new({key:'AUTOMATIC_DELETION_PROTECTION', value:'true'})
|
326
|
+
tag_keep_data = Aws::CloudFormation::Types::Tag.new({ key: 'AUTOMATIC_DELETION_PROTECTION', value: 'true' })
|
327
327
|
tags.push tag_keep_data
|
328
328
|
end
|
329
329
|
|
330
330
|
update_cluster_stack(cluster_stack_name, tags, get_stack_parameters(cluster_stack_name))
|
331
331
|
|
332
|
-
output
|
332
|
+
output 'Finito!'.green
|
333
333
|
end
|
334
334
|
|
335
335
|
def deploy_update!
|
336
|
-
output
|
336
|
+
output 'Deploy update menu'
|
337
337
|
`git pull`
|
338
338
|
|
339
|
-
output
|
340
|
-
stack_list, envs = get_stacks
|
339
|
+
output 'Recupero le informazioni sui QA attivi...'
|
340
|
+
stack_list, envs = get_stacks
|
341
341
|
|
342
342
|
env_hash = nil
|
343
|
-
|
343
|
+
if envs.empty?
|
344
|
+
output 'Nessun QA trovato'.red
|
345
|
+
exit
|
346
|
+
else
|
344
347
|
env_hash = choose do |menu|
|
345
|
-
menu.prompt =
|
348
|
+
menu.prompt = 'Scegli il QA che vuoi aggiornare: '.cyan
|
346
349
|
menu.shell = true
|
347
350
|
envs.each do |key, env|
|
348
|
-
title =
|
351
|
+
title = ''
|
349
352
|
env.each do |e|
|
350
353
|
title << "\n#{e.key.upcase}: #{e.value}"
|
351
354
|
end
|
352
|
-
msg =
|
355
|
+
msg = @prima.reduce_size(title, 1000).to_s.light_blue
|
353
356
|
menu.choice(msg) { key }
|
354
357
|
end
|
355
358
|
end
|
356
|
-
else
|
357
|
-
output "Nessun QA trovato".red
|
358
|
-
exit
|
359
359
|
end
|
360
360
|
|
361
361
|
envs[env_hash].each do |env|
|
362
|
-
unless [
|
362
|
+
unless %w[hostname_pattern_priority AUTOMATIC_DELETION_PROTECTION].include? env.key
|
363
363
|
@projects[env.key] = select_branch_to_deploy(env.key, env.value)
|
364
364
|
end
|
365
365
|
end
|
366
366
|
deploy_feature!
|
367
367
|
|
368
|
-
output
|
368
|
+
output 'Finito!'.green
|
369
369
|
end
|
370
370
|
|
371
371
|
def get_default_branch_name(projects)
|
372
372
|
projects.each_key do |project|
|
373
|
-
return projects[project]['name']
|
373
|
+
return projects[project]['name'] unless projects[project]['default_branch']
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
-
def suite_py_branches
|
378
|
-
if File.exist?(
|
379
|
-
arg_projects = YAML.load(File.read(
|
377
|
+
def suite_py_branches
|
378
|
+
if File.exist?('suitepy-projects.yml')
|
379
|
+
arg_projects = YAML.load(File.read('suitepy-projects.yml'))
|
380
380
|
|
381
381
|
@projects.merge!(arg_projects)
|
382
382
|
|
383
383
|
`rm suitepy-projects.yml`
|
384
384
|
|
385
385
|
@projects.each_key do |project|
|
386
|
-
if @projects[project].empty?
|
387
|
-
@projects[project] = choose_branch_to_deploy(project, true)
|
388
|
-
end
|
386
|
+
@projects[project] = choose_branch_to_deploy(project, true) if @projects[project].empty?
|
389
387
|
end
|
390
388
|
end
|
391
389
|
end
|
392
390
|
|
393
|
-
def get_git_user
|
391
|
+
def get_git_user
|
394
392
|
`git config user.name`.gsub(/[^A-Za-z]/, '').gsub("\n", '')
|
395
393
|
end
|
396
394
|
|
397
|
-
def get_git_mail
|
395
|
+
def get_git_mail
|
398
396
|
`git config user.email`.gsub("\n", '')
|
399
397
|
end
|
400
398
|
|
401
399
|
def qainit_deploy!(quiet = false)
|
402
|
-
`git checkout master && git pull && git remote prune origin`
|
400
|
+
`git checkout master && git fetch && git pull && git remote prune origin`
|
403
401
|
|
404
|
-
`git
|
402
|
+
`git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done`
|
405
403
|
|
406
404
|
default_name = get_default_branch_name @projects
|
407
405
|
feature_number = ''
|
@@ -418,7 +416,7 @@ class Release
|
|
418
416
|
`git checkout -b #{branch_name}`
|
419
417
|
end
|
420
418
|
|
421
|
-
File.open(
|
419
|
+
File.open('projects.yml', 'w') { |file| file.write(@projects.to_yaml) }
|
422
420
|
|
423
421
|
update_drone_yml!
|
424
422
|
|
@@ -437,7 +435,7 @@ class Release
|
|
437
435
|
git_user = get_git_user
|
438
436
|
# stampiamo la lista
|
439
437
|
chosen_branch = choose do |menu|
|
440
|
-
menu.prompt =
|
438
|
+
menu.prompt = 'Scegli il QA che vuoi aggiornare: '.cyan
|
441
439
|
menu.shell = true
|
442
440
|
former_branches.delete('master')
|
443
441
|
former_branches.each_with_index do |branch, index|
|
@@ -452,14 +450,14 @@ class Release
|
|
452
450
|
# aggiornare il commit (revision a cui fa riferimento)
|
453
451
|
|
454
452
|
# leggo il file projects.yml / recupero i nomi dei branch / riscrivo tutto
|
455
|
-
projects = YAML.load(File.read(
|
453
|
+
projects = YAML.load(File.read('projects.yml'))
|
456
454
|
|
457
455
|
projects.each do |key, project|
|
458
456
|
@projects[key] = select_branch_to_deploy(key, project['name'])
|
459
457
|
@projects[key]['default_branch'] = project['default_branch']
|
460
458
|
end
|
461
459
|
|
462
|
-
File.open(
|
460
|
+
File.open('projects.yml', 'w') { |file| file.write(@projects.to_yaml) }
|
463
461
|
|
464
462
|
update_drone_yml!
|
465
463
|
|
@@ -475,7 +473,7 @@ class Release
|
|
475
473
|
if selection.nil?
|
476
474
|
# stampiamo la lista
|
477
475
|
chosen_branch = choose do |menu|
|
478
|
-
menu.prompt =
|
476
|
+
menu.prompt = 'Scegli il QA che vuoi spegnere: '.cyan
|
479
477
|
menu.shell = true
|
480
478
|
git_user = get_git_user
|
481
479
|
former_branches.delete('master')
|
@@ -494,10 +492,10 @@ class Release
|
|
494
492
|
end
|
495
493
|
|
496
494
|
def qainit_drone_shutdown!
|
497
|
-
output
|
495
|
+
output 'Recupero le informazioni sui QA attivi...'
|
498
496
|
stack_list, envs = get_stacks
|
499
497
|
|
500
|
-
env_hash =
|
498
|
+
env_hash = 'qa-' + get_deploy_id
|
501
499
|
|
502
500
|
cluster_stack_name = nil
|
503
501
|
stacks_to_delete = []
|
@@ -507,6 +505,7 @@ class Release
|
|
507
505
|
cluster_stack_name = stack.stack_name
|
508
506
|
else
|
509
507
|
break unless stack.stack_name.match(/#{env_hash}$/)
|
508
|
+
|
510
509
|
stacks_to_delete.push(stack.stack_name)
|
511
510
|
delete_stack(stack.stack_name)
|
512
511
|
end
|
@@ -516,47 +515,45 @@ class Release
|
|
516
515
|
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
517
516
|
if stack_exists?(cluster_stack_name)
|
518
517
|
aggregator_enabled = get_stack_tags(cluster_stack_name).detect do |tag|
|
519
|
-
tag.key ===
|
518
|
+
tag.key === 'hostname_pattern_priority' and tag.value === '1'
|
520
519
|
end.is_a?(Aws::CloudFormation::Types::Tag)
|
521
520
|
|
522
|
-
if aggregator_enabled
|
523
|
-
dns_to_staging(env_hash)
|
524
|
-
end
|
521
|
+
dns_to_staging(env_hash) if aggregator_enabled
|
525
522
|
end
|
526
523
|
|
527
524
|
# Se non ha finito di cancellare le altre non si puo' cancellare il cluster
|
528
|
-
output
|
525
|
+
output 'Attendo 10 secondi per poter eliminare il cluster ECS'
|
529
526
|
|
530
527
|
while stacks_to_delete.length > 0
|
531
528
|
sleep 13
|
532
529
|
stacks_to_delete.each do |stack_name|
|
533
|
-
stacks_to_delete
|
530
|
+
stacks_to_delete -= [stack_name] unless stack_exists?(stack_name)
|
534
531
|
end
|
535
|
-
output "Stack ancora attivi: #{stacks_to_delete.length
|
532
|
+
output "Stack ancora attivi: #{stacks_to_delete.length}. Attendo altri 10 secondi per eliminare il cluster ECS"
|
536
533
|
end
|
537
534
|
|
538
535
|
delete_stack(cluster_stack_name) if stack_exists?(cluster_stack_name)
|
539
536
|
delete_stack(@base_stack_name_alb + env_hash[3..8]) if stack_exists?(@base_stack_name_alb + env_hash[3..8])
|
540
537
|
delete_stack(@base_stack_name_alb_ws + env_hash[3..8]) if stack_exists?(@base_stack_name_alb_ws + env_hash[3..8])
|
541
538
|
`git checkout master && git push origin --delete ${DRONE_BRANCH}`
|
542
|
-
output
|
543
|
-
delete_lighthouse_dns
|
544
|
-
output
|
539
|
+
output 'Cancello il record DNS utilizzato da Lighthouse'
|
540
|
+
delete_lighthouse_dns
|
541
|
+
output 'Finito!'.green
|
545
542
|
end
|
546
543
|
|
547
544
|
def qainit_write_output(file_message, output_message)
|
548
545
|
`mkdir -p /etc/qainit-output`
|
549
|
-
qa_file_name =
|
546
|
+
qa_file_name = '/etc/qainit-output/url_qa'
|
550
547
|
File.open(qa_file_name + '.txt', 'w') { |file| file.write(file_message) }
|
551
548
|
output "#{output_message} #{qa_file_name}".green
|
552
549
|
end
|
553
550
|
|
554
|
-
def update_drone_yml!
|
551
|
+
def update_drone_yml!
|
555
552
|
drone_yml = File.read('.drone.yml')
|
556
553
|
@projects.each do |key, project|
|
557
554
|
drone_yml = drone_yml.gsub(/#{key}@.+\n/, "#{key}@#{project['revision']}\n")
|
558
555
|
end
|
559
|
-
File.open(
|
556
|
+
File.open('.drone.yml', 'w') do |f|
|
560
557
|
f.write(drone_yml)
|
561
558
|
end
|
562
559
|
end
|
@@ -571,10 +568,9 @@ class Release
|
|
571
568
|
end
|
572
569
|
|
573
570
|
def get_alb_host(stack_name)
|
574
|
-
|
575
|
-
when stack_name.include?('alb-http-public')
|
571
|
+
if stack_name.include?('alb-http-public')
|
576
572
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
577
|
-
|
573
|
+
elsif stack_name.include?('alb-ws-public')
|
578
574
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
579
575
|
end
|
580
576
|
resp = describe_stack_resource(stack_name, logical_resource_id)
|
@@ -590,8 +586,8 @@ class Release
|
|
590
586
|
def choose_branch_to_deploy(project_name, select_master = false)
|
591
587
|
# chiamare api octokit per recuperare i branch/commit
|
592
588
|
output "Recupero la lista dei branch del progetto #{project_name}..."
|
593
|
-
branches = @gh.branches("primait/#{project_name}", {per_page: 100})
|
594
|
-
master_branch = branches.select {|branch| branch[:name] == 'master'}[0]
|
589
|
+
branches = @gh.branches("primait/#{project_name}", { per_page: 100 })
|
590
|
+
master_branch = branches.select { |branch| branch[:name] == 'master' }[0]
|
595
591
|
|
596
592
|
if select_master || branches.length == 1
|
597
593
|
branch_name = 'master'
|
@@ -613,7 +609,7 @@ class Release
|
|
613
609
|
end
|
614
610
|
end
|
615
611
|
|
616
|
-
chosen_branch = branches.select {|branch| branch[:name] == branch_name}[0]
|
612
|
+
chosen_branch = branches.select { |branch| branch[:name] == branch_name }[0]
|
617
613
|
name = branch_name
|
618
614
|
revision = chosen_branch[:commit][:sha]
|
619
615
|
{ 'name' => name, 'revision' => revision[0..14], 'default_branch' => select_master }
|
@@ -628,7 +624,7 @@ class Release
|
|
628
624
|
{ 'name' => name, 'revision' => revision[0..14], 'committer' => committer_email }
|
629
625
|
end
|
630
626
|
|
631
|
-
def get_stacks
|
627
|
+
def get_stacks
|
632
628
|
envs = {}
|
633
629
|
stack_list = stack_list()
|
634
630
|
stack_list.each do |stack|
|
@@ -637,10 +633,10 @@ class Release
|
|
637
633
|
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
638
634
|
end
|
639
635
|
end
|
640
|
-
|
636
|
+
[stack_list, envs]
|
641
637
|
end
|
642
638
|
|
643
|
-
def get_clusters
|
639
|
+
def get_clusters
|
644
640
|
envs = {}
|
645
641
|
cluster_list = cluster_list()
|
646
642
|
cluster_list.each do |stack|
|
@@ -649,63 +645,65 @@ class Release
|
|
649
645
|
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
650
646
|
end
|
651
647
|
end
|
652
|
-
|
648
|
+
[cluster_list, envs]
|
653
649
|
end
|
654
650
|
|
655
|
-
def hostname_pattern_priority
|
656
|
-
(Time.now.to_i.to_s[-4..-1].to_i + Random.rand(
|
651
|
+
def hostname_pattern_priority
|
652
|
+
(Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40_000)).to_s
|
657
653
|
end
|
658
654
|
|
659
655
|
def select_branches(project_names = nil)
|
660
|
-
output
|
656
|
+
output 'Deploy feature menu'
|
661
657
|
if project_names.nil?
|
662
|
-
@projects.each{ |key,
|
658
|
+
@projects.each { |key, _value| @projects[key] = choose_branch_to_deploy(key) }
|
663
659
|
else
|
664
660
|
project_names.each do |project|
|
665
661
|
@projects[project] = choose_branch_to_deploy(project)
|
666
662
|
end
|
667
663
|
@projects.each_key do |branch_project|
|
668
|
-
|
664
|
+
unless project_names.include? branch_project
|
665
|
+
@projects[branch_project] = choose_branch_to_deploy(branch_project, true)
|
666
|
+
end
|
669
667
|
end
|
670
668
|
end
|
671
669
|
end
|
672
670
|
end
|
673
671
|
|
674
672
|
def help_content
|
675
|
-
|
673
|
+
<<~HELP
|
676
674
|
|
677
|
-
twig-feature
|
678
|
-
===========
|
675
|
+
twig-feature
|
676
|
+
===========
|
679
677
|
|
680
|
-
Manage feature branches
|
678
|
+
Manage feature branches
|
681
679
|
|
682
|
-
Synopsis
|
683
|
-
--------
|
680
|
+
Synopsis
|
681
|
+
--------
|
684
682
|
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
683
|
+
twig release start
|
684
|
+
twig release finish
|
685
|
+
twig release deploy
|
686
|
+
twig release aggregator
|
689
687
|
|
690
|
-
Description
|
691
|
-
-----------
|
688
|
+
Description
|
689
|
+
-----------
|
692
690
|
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
691
|
+
start creates a new feature branch
|
692
|
+
finish finishes the feature by merging to dev and master
|
693
|
+
qainit deploys a new environment with selected branches from every project
|
694
|
+
qainit $PROJECT_NAME deploys a new environment allowing to selected a branch from the input project (everything else is master)
|
695
|
+
qainit shutdown deletes a specific qa environment
|
698
696
|
|
699
|
-
Available only to devops (from artemide)
|
700
|
-
-----------
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
697
|
+
Available only to devops (from artemide)
|
698
|
+
-----------
|
699
|
+
deploy deploys the feature branch to a temporary AWS Elastic Beanstalk env
|
700
|
+
deploy stop destroys the AWS Elastic Beanstalk env
|
701
|
+
deploy update updates a feature branch with current branches
|
702
|
+
deploy lock protects a qa environment from automatic deletion
|
703
|
+
aggregator enable/disable directs comparator's staging environments to a qa/staging
|
706
704
|
|
707
|
-
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
708
|
-
Author: Andrea Usuelli <https://github.com/andreausu>
|
705
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
706
|
+
Author: Andrea Usuelli <https://github.com/andreausu>
|
709
707
|
|
710
708
|
HELP
|
711
709
|
end
|
@@ -718,9 +716,7 @@ if args.include?('--help')
|
|
718
716
|
end
|
719
717
|
|
720
718
|
gem_update = true
|
721
|
-
if args.include?('no-gem-update')
|
722
|
-
gem_update = false
|
723
|
-
end
|
719
|
+
gem_update = false if args.include?('no-gem-update')
|
724
720
|
|
725
721
|
args.delete('no-gem-update')
|
726
722
|
|
data/bin/twig-update-ami
CHANGED
@@ -39,15 +39,11 @@ class TwigUpdateAmi
|
|
39
39
|
end
|
40
40
|
|
41
41
|
update_stack_reuse_template(stack, stack_parameters)
|
42
|
+
# update stack sequentially to avoid alb throttling
|
43
|
+
wait_for_stack_ready(stack, %w[CREATE_FAILED ROLLBACK_IN_PROGRESS ROLLBACK_FAILED DELETE_IN_PROGRESS DELETE_FAILED DELETE_COMPLETE UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE ROLLBACK_COMPLETE])
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
stacks.each do |stack|
|
46
|
-
next if stack.include?('qa')
|
47
|
-
|
48
|
-
wait_for_stack_ready(stack, %w[CREATE_FAILED ROLLBACK_IN_PROGRESS ROLLBACK_FAILED DELETE_IN_PROGRESS DELETE_FAILED DELETE_COMPLETE UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE ROLLBACK_COMPLETE])
|
49
|
-
end
|
50
|
-
|
51
47
|
output 'Saving new ami in ami_state.yml'.light_green
|
52
48
|
File.open(@state_path, 'r') do |f|
|
53
49
|
@config = YAML.load(f.read)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prima-twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: aws-sdk-autoscaling
|