prima-twig 1.3.1 → 1.3.6

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