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 +4 -4
- data/bin/cps-property-generator +7 -5
- data/lib/generator/generator.rb +22 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f659265beb057cc6e807215df12702562307e50
|
4
|
+
data.tar.gz: 58a223834ecda08eea38a5f9a21ad6cbdf39f37d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbda7d164c992be4eab086b2f770dee1c8adbefe259ae6c12da695ba09d6f3c8ffbaa90a76e51e7572cb2143d7c26609c3ac39231d59a4af964daff555267e07
|
7
|
+
data.tar.gz: bf99d2880a883f34fc8047a61fff2b55c51307faa71d450780a30f01ef29f40d882c622e3d547df0e27e7d3ca127e4f73b12ce886c338c7971948e23f05284ff
|
data/bin/cps-property-generator
CHANGED
@@ -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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
|
data/lib/generator/generator.rb
CHANGED
@@ -37,22 +37,33 @@ module PropertyGenerator
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def upload(out, config)
|
40
|
-
|
40
|
+
upload_bucket = config['upload_bucket']
|
41
|
+
upload_region = config['upload_region']
|
41
42
|
|
42
|
-
if
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
51
|
-
|
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
|
-
|
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
|