cps-property-generator 0.2.19 → 0.2.20

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
  SHA1:
3
- metadata.gz: a0cc064b6d0d8fafe9847384a929bd11f5bb9a54
4
- data.tar.gz: 62a7bc3e50dfd64f1573098a37c762470d7ac481
3
+ metadata.gz: 2f659265beb057cc6e807215df12702562307e50
4
+ data.tar.gz: 58a223834ecda08eea38a5f9a21ad6cbdf39f37d
5
5
  SHA512:
6
- metadata.gz: a447cbbe279d63222df061d4154b07d177ff433a54949a8d94d136ddbb37ae7893d689845460b68f10a144253ab29c0c4bf9b2e908d317f281ae242c5c09eb5b
7
- data.tar.gz: a22afe3b1933db8c83a9b43f16da69b6fefdcd364182a8f733da9588b7a84e1b98ddb0399a07cc84374658c36106ff724f7b959e22c2beb94ca0b75f67760439
6
+ metadata.gz: dbda7d164c992be4eab086b2f770dee1c8adbefe259ae6c12da695ba09d6f3c8ffbaa90a76e51e7572cb2143d7c26609c3ac39231d59a4af964daff555267e07
7
+ data.tar.gz: bf99d2880a883f34fc8047a61fff2b55c51307faa71d450780a30f01ef29f40d882c622e3d547df0e27e7d3ca127e4f73b12ce886c338c7971948e23f05284ff
@@ -13,17 +13,19 @@ class GeneratorCLI < ::Thor
13
13
  option 'upload_account', banner: 'UPLOAD_ACCOUNT', type: :string, desc: 'The account you are uploading properties to'
14
14
  option 'upload_region', banner: 'UPLOAD_REGION', type: :string, desc: 'The region your property bucket is in'
15
15
  option 'upload_bucket', banner: 'UPLOAD_BUCKET', type: :string, desc: 'The bucket you are uploading properties to.'
16
+ option 'upload_all', banner: 'UPLOAD_ALL', type: :boolean, desc: 'Whether to upload all envs and accounts to a single bucket', :default => false
16
17
 
17
18
  def generate
18
19
 
19
20
  generator = PropertyGenerator::Generator.new(options)
20
21
  out = generator.generate
21
22
  if options['upload']
22
- if options['upload_account'].nil? || options['upload_region'].nil? && options['upload_bucket'].nil?
23
- puts 'Please specify upload configs'
24
- else
25
- generator.upload(out, options)
26
- end
23
+ abort('Did not specify an upload bucket') if options['upload_bucket'].nil?
24
+ abort('Did not specify an upload region') if options['upload_region'].nil?
25
+
26
+ abort('Did not specify upload configs') if !options['upload_all'] && options['upload_account'].nil?
27
+
28
+ generator.upload(out, options)
27
29
  end
28
30
  end
29
31
 
@@ -37,22 +37,33 @@ module PropertyGenerator
37
37
  end
38
38
 
39
39
  def upload(out, config)
40
- account = config['upload_account']
40
+ upload_bucket = config['upload_bucket']
41
+ upload_region = config['upload_region']
41
42
 
42
- if !@accounts.include?(account.to_i)
43
- abort("The specified account (#{account}) is not configured, please add it to config/config.yml")
44
- end
43
+ if config['upload_all']
44
+ _upload_files(out.sort) do |file|
45
+ file_region = file.split("/")[-2]
46
+ file_account = file.split("/")[-3]
45
47
 
46
- upload_account = config['upload_account']
47
- upload_region = config['upload_region']
48
- upload_bucket = config['upload_bucket']
48
+ PropertyGenerator.sync(upload_region, file_account, upload_bucket, file, file_region)
49
+ end
50
+ else
51
+ upload_account = config['upload_account']
52
+ abort("The specified account (#{upload_account}) is not configured, please add it to config/config.yml") unless @accounts.include?(upload_account)
53
+
54
+ upload_out = out.select { |file| file.include?("#{upload_account}") && file.include?("#{upload_region}") }
55
+ _upload_files(upload_out) do |file|
56
+ file_region = file.split("/")[-2]
57
+ PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region)
58
+ end
59
+ end
60
+ end
49
61
 
50
- upload_out = out.select { |file| file.include?("#{upload_account}") && file.include?("#{upload_region}") }
51
- upload_out.each_slice(20) do |file_slice|
62
+ def _upload_files(files)
63
+ files.each_slice(20) do |file_slice|
52
64
  file_slice.map do |file|
53
65
  Thread.new do
54
- file_region = file.split("/")[-2]
55
- PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region)
66
+ yield file
56
67
  end
57
68
  end.each(&:join)
58
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cps-property-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.19
4
+ version: 0.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Call