cps-property-generator 0.2.6 → 0.2.11
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 +0 -1
- data/lib/generator/generator.rb +9 -2
- data/lib/generator/service.rb +24 -2
- data/lib/helpers/helpers.rb +6 -2
- data/lib/linter/config_linter.rb +3 -3
- 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: a336b0ce14011377bc50c3c669993f436fd8e31d
|
4
|
+
data.tar.gz: e9d5899eae6a9b456e3d53c97d588c7757013503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a38fe0b448efba004406062b8bdd8736fc44195d94351b07bf1b859e327dcad44b07d194ba778784eeb7f4eee6bc592f6082628abc926a48a5d41357b360868
|
7
|
+
data.tar.gz: 914944ab88f0e717a9e4231f40ce0eb8806f27de29f7b4d1c61e79eceb05ab5a87c8869e167135ac317052b71cfbe8fa4707b3867bd92c92c80887d55f975282
|
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,13 +30,19 @@ 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']
|
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"]}"
|
data/lib/linter/config_linter.rb
CHANGED
@@ -14,7 +14,7 @@ module PropertyGenerator
|
|
14
14
|
else
|
15
15
|
tests = ['config_has_correct_keys',
|
16
16
|
'environment_configs_match_environments_list',
|
17
|
-
'
|
17
|
+
'environment_configs_have_valid_region_and_account_values',
|
18
18
|
'environment_configs_have_well_formatted_interpolations',
|
19
19
|
'config_file_is_present']
|
20
20
|
end
|
@@ -61,12 +61,12 @@ module PropertyGenerator
|
|
61
61
|
status
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def environment_configs_have_valid_region_and_account_values
|
65
65
|
status = {status: 'pass', error: ''}
|
66
66
|
environments_missmatch_values = []
|
67
67
|
any_missmatches = false
|
68
68
|
@configs['environment_configs'].keys.each do |environment|
|
69
|
-
unless
|
69
|
+
unless (@configs['environment_configs'][environment].key?('region')) && @configs['accounts'].include?(@configs['environment_configs'][environment]['account'])
|
70
70
|
environments_missmatch_values << environment
|
71
71
|
any_missmatches = true
|
72
72
|
end
|
@@ -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.11
|
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
|