cps-property-generator 0.2.7 → 0.2.13
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.
- checksums.yaml +4 -4
- data/bin/cps-property-generator +0 -1
- data/lib/generator/generator.rb +18 -6
- data/lib/generator/service.rb +24 -2
- data/lib/helpers/helpers.rb +6 -2
- data/lib/linter/services_linter.rb +2 -2
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 202188fe59edafc4ddb51f8b4d285dc8a38ede94
|
4
|
+
data.tar.gz: 387b7905cfdb7472d09a426fda83f633c41794d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5b14643b19438c1be8cc65b90c5d4bda7bcf5bd710d1a228396982b41c809a2d0c844930c175dae3026f6eb8c4da20b79477045181d3bbe515f8c15f8c1043
|
7
|
+
data.tar.gz: 3002871e1b5f17a67e5a5b38f84781e4147d1dacbbb5bc6f30c02cc8ec5af4c3d8397243a0fe8ac42d31a4a8a9e6d9d5f33e4055436d3478e47d7117a77508f6
|
data/bin/cps-property-generator
CHANGED
data/lib/generator/generator.rb
CHANGED
@@ -15,10 +15,11 @@ module PropertyGenerator
|
|
15
15
|
@configs = PropertyGenerator::Config.new(project_path)
|
16
16
|
@globals = PropertyGenerator::Globals.new(project_path, @configs)
|
17
17
|
@globals = @globals.globals
|
18
|
+
@accounts = @configs.accounts
|
19
|
+
|
18
20
|
@output_path = "#{File.expand_path(options['output'])}/properties/#{SecureRandom.hex}"
|
19
21
|
puts "Properties will be output here #{@output_path}"
|
20
22
|
@service_list = PropertyGenerator.read_services(project_path)
|
21
|
-
|
22
23
|
end
|
23
24
|
|
24
25
|
def generate
|
@@ -29,20 +30,31 @@ module PropertyGenerator
|
|
29
30
|
service_instance.service
|
30
31
|
service_instance.interpolate
|
31
32
|
|
32
|
-
out = PropertyGenerator.writer(service, service_instance.service, @configs, @output_path)
|
33
|
+
out = PropertyGenerator.writer(service, service_instance.service, @configs, @output_path, service_instance.additional_options)
|
33
34
|
(output << out).flatten!
|
34
35
|
end
|
35
36
|
output
|
36
37
|
end
|
37
38
|
|
38
39
|
def upload(out, config)
|
40
|
+
account = config['upload_account']
|
41
|
+
|
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
|
45
|
+
|
39
46
|
upload_account = config['upload_account']
|
40
47
|
upload_region = config['upload_region']
|
41
48
|
upload_bucket = config['upload_bucket']
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
|
50
|
+
upload_out = out.select { |file| file.include?("#{upload_account}") && file.include?("#{upload_region}") }
|
51
|
+
upload_out.each_slice(20) do |file_slice|
|
52
|
+
file_slice.map do |file|
|
53
|
+
Thread.new do
|
54
|
+
file_region = file.split("/")[-2]
|
55
|
+
PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region)
|
56
|
+
end
|
57
|
+
end.each(&:join)
|
46
58
|
end
|
47
59
|
end
|
48
60
|
|
data/lib/generator/service.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module PropertyGenerator
|
2
|
+
|
2
3
|
class Service
|
4
|
+
require 'active_support/core_ext/hash'
|
5
|
+
|
3
6
|
attr_accessor :service
|
7
|
+
|
4
8
|
def initialize(service_data, config, globals)
|
5
9
|
@service_data = service_data
|
6
10
|
@environments = config.environments
|
7
11
|
@globals = globals
|
8
12
|
@environment_configs = config.environment_configs
|
13
|
+
@configmapname = service_data['configname'].nil? ? nil : service_data['configname']
|
14
|
+
set_additional_options
|
9
15
|
set_service
|
10
16
|
end
|
11
17
|
|
@@ -14,10 +20,26 @@ module PropertyGenerator
|
|
14
20
|
@service = merge_service_with_globals(@globals, service_data, @environments)
|
15
21
|
end
|
16
22
|
|
23
|
+
def set_additional_options
|
24
|
+
@additional_options = {}
|
25
|
+
@additional_options['configname'] = @service_data['configname'].nil? ? nil : @service_data['configname']
|
26
|
+
@additional_options['stringdata'] = @service_data['stringdata'].nil? ? nil : @service_data['stringdata']
|
27
|
+
@additional_options['configlabels'] = @service_data['configlabels'].nil? ? nil : @service_data['configlabels']
|
28
|
+
@additional_options['secretlabels'] = @service_data['secretlabels'].nil? ? nil : @service_data['secretlabels']
|
29
|
+
end
|
30
|
+
|
31
|
+
def additional_options
|
32
|
+
@additional_options
|
33
|
+
end
|
34
|
+
|
17
35
|
def service
|
18
36
|
@service
|
19
37
|
end
|
20
38
|
|
39
|
+
def configmap_name
|
40
|
+
@configmapname
|
41
|
+
end
|
42
|
+
|
21
43
|
def interpolate
|
22
44
|
environments = @environments
|
23
45
|
#read in config
|
@@ -57,7 +79,7 @@ module PropertyGenerator
|
|
57
79
|
environment_data = data['environments'][env].dup
|
58
80
|
if data['encrypted']
|
59
81
|
encrypted = data['encrypted'][env].dup unless data['encrypted'][env].nil?
|
60
|
-
environment_data = data['environments'][env].
|
82
|
+
environment_data = data['environments'][env].deep_merge(encrypted) unless encrypted.nil?
|
61
83
|
end
|
62
84
|
if default_clone.nil?
|
63
85
|
merged = environment_data
|
@@ -85,6 +107,6 @@ module PropertyGenerator
|
|
85
107
|
output
|
86
108
|
end
|
87
109
|
|
88
|
-
|
89
110
|
end
|
111
|
+
|
90
112
|
end
|
data/lib/helpers/helpers.rb
CHANGED
@@ -54,14 +54,18 @@ module PropertyGenerator
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def writer(service_name, finalized, configs, output_path)
|
57
|
+
def writer(service_name, finalized, configs, output_path, additional_options)
|
58
58
|
output = []
|
59
59
|
envs = configs.environments
|
60
60
|
environmental_configs = configs.environment_configs
|
61
61
|
envs.each do | env|
|
62
62
|
account = environmental_configs[env]["account"]
|
63
63
|
region = environmental_configs[env]["region"]
|
64
|
-
|
64
|
+
hash = { "properties" => finalized[env] }
|
65
|
+
['configname', 'stringdata', 'configlabels', 'secretlabels'].each do |setting|
|
66
|
+
hash[setting] = additional_options[setting] if [setting] unless additional_options[setting].nil?
|
67
|
+
end
|
68
|
+
json = JSON.pretty_generate(hash)
|
65
69
|
#IF users are specifing a vpc then we will drop property files under the dir that corresponds to the vpc
|
66
70
|
if environmental_configs[env].key?("vpc") && !environmental_configs[env]["vpc"].nil?
|
67
71
|
vpc_dir = "#{output_path}/#{account}/#{region}/#{environmental_configs[env]["vpc"]}"
|
@@ -48,7 +48,7 @@ module PropertyGenerator
|
|
48
48
|
|
49
49
|
def services_have_accepted_keys
|
50
50
|
status = {status: 'pass', error: ''}
|
51
|
-
accepted_keys = ['default', 'environments', 'encrypted']
|
51
|
+
accepted_keys = ['default', 'environments', 'encrypted', 'configname', 'stringdata', 'configlabels', 'secretlabels']
|
52
52
|
services_with_unacceptable_keys = []
|
53
53
|
@services.each do |path, loaded|
|
54
54
|
loaded.keys.each do |service_key|
|
@@ -59,7 +59,7 @@ module PropertyGenerator
|
|
59
59
|
end
|
60
60
|
if services_with_unacceptable_keys != []
|
61
61
|
status[:status] = 'fail'
|
62
|
-
status[:error] = "Service files: #{services_with_unacceptable_keys} have keys other than 'default', 'environments', or '
|
62
|
+
status[:error] = "Service files: #{services_with_unacceptable_keys} have keys other than 'default', 'environments', 'encrypted', 'configname', 'stringdata' 'configlabels' or 'secretlabels'"
|
63
63
|
end
|
64
64
|
status
|
65
65
|
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.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Call
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.2.11.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.2.11.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: terminal-table
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|