cps-property-generator 0.2.20 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/bin/cps-property-generator +3 -5
- data/lib/generator/config.rb +1 -2
- data/lib/generator/generator.rb +11 -11
- data/lib/generator/globals.rb +11 -11
- data/lib/generator/service.rb +9 -19
- data/lib/helpers/helpers.rb +22 -22
- data/lib/linter/config_linter.rb +36 -37
- data/lib/linter/globals_linter.rb +35 -30
- data/lib/linter/linter.rb +24 -10
- data/lib/linter/report.rb +24 -21
- data/lib/linter/services_linter.rb +109 -70
- data/spec/lib/config_spec.rb +23 -18
- data/spec/lib/global_spec.rb +55 -30
- data/spec/lib/service_spec.rb +76 -67
- data/spec/resources/services/my-microservice-1.yml +8 -0
- metadata +52 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad999a530e887f24055f48e8481d342c2c9513a
|
4
|
+
data.tar.gz: 581fa068ac84ebb424ef6bd5bfe7d8e2eb3bb555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1bad9217c2f69cd37ae6d92ec2a3d7473b3d5372b114c681ef5c06dc5761d1a0f9e7bf074852ac10d760a14c9a13031e6ca2e735ce35db41d7b55265d02bd63
|
7
|
+
data.tar.gz: 4ba83409ee857e560b09ab8047c22265d56cf95ecfec19199001f7c39eea5ea137a60c0b310a53786c449e35ee793eb62051ff36a52991da87b9f7975773e00f
|
data/README.md
CHANGED
@@ -77,6 +77,9 @@ touch globals.yml
|
|
77
77
|
1. Create a folder called `environments` inside your folder named after your account.
|
78
78
|
2. Inside the `environments` folder create a yaml file named after the environment you would like to define globals for. Only environments defined in your config are supported. The environment must also be mapped in the config to the account the sharing the same name as the folder the environment global yaml file lives in.
|
79
79
|
3. In the newly created environment's yaml file you may define your globals.
|
80
|
+
##### Hierarchical Merging
|
81
|
+
Hierarchical merging follows the following equation `(account.yml < service::default) < (region.yml < service::region)`. So the main thing to note that may be counterintuitive is that service defaults do not overwrite a region default.
|
82
|
+
|
80
83
|
###### Encrypted Properties in Environment Globals
|
81
84
|
If you would like to pass in an encrypted property to all services in a given environment, you can pass in ckrt encrypted values by having an `encrypted` block in your environment global file.
|
82
85
|
```yaml
|
data/bin/cps-property-generator
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
2
|
require 'thor'
|
4
3
|
require 'yaml'
|
5
|
-
require_relative '../lib/generator/generator
|
6
|
-
require_relative '../lib/linter/linter
|
7
|
-
class GeneratorCLI < ::Thor
|
4
|
+
require_relative '../lib/generator/generator'
|
5
|
+
require_relative '../lib/linter/linter'
|
8
6
|
|
7
|
+
class GeneratorCLI < ::Thor
|
9
8
|
desc 'generate', 'Generate properties'
|
10
9
|
option 'project_path', banner: 'PROJECT_PATH', type: :string, desc: 'Path to the property project to generate properties for'
|
11
10
|
option 'output', banner: 'OUTPUT', type: :string, desc: 'Output path for locally dumping generated outputs', :default => '/tmp/'
|
@@ -16,7 +15,6 @@ class GeneratorCLI < ::Thor
|
|
16
15
|
option 'upload_all', banner: 'UPLOAD_ALL', type: :boolean, desc: 'Whether to upload all envs and accounts to a single bucket', :default => false
|
17
16
|
|
18
17
|
def generate
|
19
|
-
|
20
18
|
generator = PropertyGenerator::Generator.new(options)
|
21
19
|
out = generator.generate
|
22
20
|
if options['upload']
|
data/lib/generator/config.rb
CHANGED
data/lib/generator/generator.rb
CHANGED
@@ -11,20 +11,20 @@ module PropertyGenerator
|
|
11
11
|
# purpose: initialize globals and configs
|
12
12
|
# serve as a broker between tasks
|
13
13
|
def initialize(options)
|
14
|
-
project_path =
|
14
|
+
project_path = File.expand_path(options['project_path'])
|
15
15
|
@configs = PropertyGenerator::Config.new(project_path)
|
16
16
|
@globals = PropertyGenerator::Globals.new(project_path, @configs)
|
17
17
|
@globals = @globals.globals
|
18
18
|
@accounts = @configs.accounts
|
19
19
|
|
20
|
-
@output_path =
|
20
|
+
@output_path = "#{File.expand_path(options['output'])}/properties/#{SecureRandom.hex}"
|
21
21
|
puts "Properties will be output here #{@output_path}"
|
22
22
|
@service_list = PropertyGenerator.read_services(project_path)
|
23
23
|
end
|
24
24
|
|
25
25
|
def generate
|
26
26
|
output = []
|
27
|
-
@service_list.each do |
|
27
|
+
@service_list.each do |service, path|
|
28
28
|
PropertyGenerator.config_enforcer(@configs.environment_configs)
|
29
29
|
service_instance = PropertyGenerator::Service.new(YAML.load_file(path), @configs, @globals)
|
30
30
|
service_instance.service
|
@@ -42,18 +42,20 @@ module PropertyGenerator
|
|
42
42
|
|
43
43
|
if config['upload_all']
|
44
44
|
_upload_files(out.sort) do |file|
|
45
|
-
file_region = file.split(
|
46
|
-
file_account = file.split(
|
45
|
+
file_region = file.split('/')[-2]
|
46
|
+
file_account = file.split('/')[-3]
|
47
47
|
|
48
48
|
PropertyGenerator.sync(upload_region, file_account, upload_bucket, file, file_region)
|
49
49
|
end
|
50
50
|
else
|
51
|
-
upload_account = config['upload_account']
|
52
|
-
|
51
|
+
upload_account = config['upload_account'].strip
|
52
|
+
unless @accounts.map { |a| a.to_s.strip }.include?(upload_account)
|
53
|
+
abort("The specified account (#{upload_account}) is not configured, please add it to config/config.yml")
|
54
|
+
end
|
53
55
|
|
54
|
-
upload_out = out.select { |file| file.include?(
|
56
|
+
upload_out = out.select { |file| file.include?(upload_account) && file.include?(upload_region) }
|
55
57
|
_upload_files(upload_out) do |file|
|
56
|
-
file_region = file.split(
|
58
|
+
file_region = file.split('/')[-2]
|
57
59
|
PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region)
|
58
60
|
end
|
59
61
|
end
|
@@ -68,7 +70,5 @@ module PropertyGenerator
|
|
68
70
|
end.each(&:join)
|
69
71
|
end
|
70
72
|
end
|
71
|
-
|
72
73
|
end
|
73
74
|
end
|
74
|
-
|
data/lib/generator/globals.rb
CHANGED
@@ -14,10 +14,9 @@ module PropertyGenerator
|
|
14
14
|
@globals ||= condense_globals
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
def get_main_global
|
19
18
|
top_level = {}
|
20
|
-
if File.
|
19
|
+
if File.exist?("#{@project_path}/globals/globals.yml")
|
21
20
|
top_level = YAML.load_file("#{@project_path}/globals/globals.yml")
|
22
21
|
end
|
23
22
|
top_level
|
@@ -26,9 +25,10 @@ module PropertyGenerator
|
|
26
25
|
def get_account_globals
|
27
26
|
data = {}
|
28
27
|
@accounts.each do |account|
|
29
|
-
next unless Dir.
|
28
|
+
next unless Dir.exist?("#{@project_path}/globals/accounts/#{account}")
|
29
|
+
|
30
30
|
account_default_file = "#{@project_path}/globals/accounts/#{account}/#{account}.yml"
|
31
|
-
data[account] = YAML.load_file(account_default_file) if File.
|
31
|
+
data[account] = YAML.load_file(account_default_file) if File.exist?(account_default_file)
|
32
32
|
end
|
33
33
|
data
|
34
34
|
end
|
@@ -36,14 +36,16 @@ module PropertyGenerator
|
|
36
36
|
def get_environment_globals
|
37
37
|
data = {}
|
38
38
|
@accounts.each do |account|
|
39
|
-
next unless Dir.
|
39
|
+
next unless Dir.exist?("#{@project_path}/globals/accounts/#{account}/environments")
|
40
|
+
|
40
41
|
data[account] = {}
|
41
42
|
@environments.each do |env|
|
42
|
-
next unless File.
|
43
|
+
next unless File.exist?("#{@project_path}/globals/accounts/#{account}/environments/#{env}.yml")
|
44
|
+
|
43
45
|
data[account][env] = YAML.load_file("#{@project_path}/globals/accounts/#{account}/environments/#{env}.yml")
|
44
46
|
unless data[account][env]['encrypted'].nil?
|
45
47
|
encrypted = data[account][env]['encrypted'].dup
|
46
|
-
not_encrypted = data[account][env].reject { |k,_| k == 'encrypted' }
|
48
|
+
not_encrypted = data[account][env].reject { |k, _| k == 'encrypted' }
|
47
49
|
data[account][env] = not_encrypted.deep_merge(encrypted)
|
48
50
|
end
|
49
51
|
end
|
@@ -51,8 +53,7 @@ module PropertyGenerator
|
|
51
53
|
data
|
52
54
|
end
|
53
55
|
|
54
|
-
|
55
|
-
#merge environment globals with account globals.
|
56
|
+
# merge environment globals with account globals.
|
56
57
|
def condense_globals
|
57
58
|
condensed = {}
|
58
59
|
# get account and the environmental hash's for said account
|
@@ -62,7 +63,7 @@ module PropertyGenerator
|
|
62
63
|
# nothing to do here if everything is empty
|
63
64
|
return condensed if environment_globals.empty? && account_globals.empty? && main_global.empty?
|
64
65
|
|
65
|
-
environment_globals.each do |account, env_global
|
66
|
+
environment_globals.each do |account, env_global|
|
66
67
|
# get the env and the values
|
67
68
|
env_global.each do |env, hash|
|
68
69
|
account_globals[account] ||= {}
|
@@ -85,6 +86,5 @@ module PropertyGenerator
|
|
85
86
|
end
|
86
87
|
condensed
|
87
88
|
end
|
88
|
-
|
89
89
|
end
|
90
90
|
end
|
data/lib/generator/service.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module PropertyGenerator
|
2
|
-
|
3
2
|
class Service
|
4
3
|
require 'active_support/core_ext/hash'
|
5
4
|
|
6
5
|
attr_accessor :service
|
6
|
+
attr_reader :additional_options
|
7
7
|
|
8
8
|
def initialize(service_data, config, globals)
|
9
9
|
@service_data = service_data
|
@@ -28,24 +28,16 @@ module PropertyGenerator
|
|
28
28
|
@additional_options['secretlabels'] = @service_data['secretlabels'].nil? ? nil : @service_data['secretlabels']
|
29
29
|
end
|
30
30
|
|
31
|
-
def additional_options
|
32
|
-
@additional_options
|
33
|
-
end
|
34
|
-
|
35
|
-
def service
|
36
|
-
@service
|
37
|
-
end
|
38
|
-
|
39
31
|
def configmap_name
|
40
32
|
@configmapname
|
41
33
|
end
|
42
34
|
|
43
35
|
def interpolate
|
44
36
|
environments = @environments
|
45
|
-
#read in config
|
46
|
-
#interate through environment and substitute config for values for that environment
|
47
|
-
environments.each do |
|
48
|
-
#get the map of config for a env
|
37
|
+
# read in config
|
38
|
+
# interate through environment and substitute config for values for that environment
|
39
|
+
environments.each do |env|
|
40
|
+
# get the map of config for a env
|
49
41
|
interpolations = @environment_configs[env]['interpolations']
|
50
42
|
|
51
43
|
# Recursively interate through the properties for an environment and gsub the config
|
@@ -59,7 +51,7 @@ module PropertyGenerator
|
|
59
51
|
|
60
52
|
def interpolate_nested_properties(service_env, interpolations)
|
61
53
|
interpolations.each do |matcher_key, matcher_value|
|
62
|
-
service_env.each { |k,v|
|
54
|
+
service_env.each { |k, v| service_env[k] = v.gsub("{#{matcher_key}}", matcher_value) if v.class == String && v.include?("{#{matcher_key}}") }
|
63
55
|
service_env.values.each do |v|
|
64
56
|
interpolate_nested_properties(v, interpolations) if v.class == Hash
|
65
57
|
v.each_with_index do |val, idx|
|
@@ -70,7 +62,7 @@ module PropertyGenerator
|
|
70
62
|
end
|
71
63
|
|
72
64
|
def merge_env_default(data, environments)
|
73
|
-
#creates a hash of the environments merged with the defaults
|
65
|
+
# creates a hash of the environments merged with the defaults
|
74
66
|
# {service => {env1 => {properties},
|
75
67
|
# env2 => {properties}
|
76
68
|
# }
|
@@ -80,7 +72,7 @@ module PropertyGenerator
|
|
80
72
|
|
81
73
|
environments.each do |env|
|
82
74
|
default_clone = default.dup
|
83
|
-
#if nil, use set to environments as nothing to merge env with
|
75
|
+
# if nil, use set to environments as nothing to merge env with
|
84
76
|
data['environments'] ||= {}
|
85
77
|
data['environments'][env] ||= {}
|
86
78
|
environment_data = data['environments'][env].dup
|
@@ -99,7 +91,7 @@ module PropertyGenerator
|
|
99
91
|
end
|
100
92
|
|
101
93
|
def merge_service_with_globals(globals_data, service_data, environments)
|
102
|
-
#service will now overwrite globals, merging will be done for each environment
|
94
|
+
# service will now overwrite globals, merging will be done for each environment
|
103
95
|
output = {}
|
104
96
|
envs = environments
|
105
97
|
envs.each do |env|
|
@@ -113,7 +105,5 @@ module PropertyGenerator
|
|
113
105
|
end
|
114
106
|
output
|
115
107
|
end
|
116
|
-
|
117
108
|
end
|
118
|
-
|
119
109
|
end
|
data/lib/helpers/helpers.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require_relative '../helpers/helpers'
|
2
|
+
|
2
3
|
module PropertyGenerator
|
3
4
|
require 'json'
|
4
5
|
require 'fileutils'
|
5
6
|
require 'aws-sdk-s3'
|
6
7
|
class << self
|
7
|
-
|
8
8
|
def test_runner(object, test_list)
|
9
9
|
results = {}
|
10
10
|
test_list.each do |test|
|
@@ -14,9 +14,9 @@ module PropertyGenerator
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_list_of_files(path, ignore_list)
|
17
|
-
#Returns a list of files in given path
|
18
|
-
#Ignores files in a given ignore list
|
19
|
-
Dir.glob(path
|
17
|
+
# Returns a list of files in given path
|
18
|
+
# Ignores files in a given ignore list
|
19
|
+
Dir.glob("#{path}/**/*").select { |e| File.file?(e) unless ignore_list.include?(e.split('/')[-1]) }
|
20
20
|
end
|
21
21
|
|
22
22
|
def valid_paths(path)
|
@@ -26,7 +26,7 @@ module PropertyGenerator
|
|
26
26
|
begin
|
27
27
|
YAML.load_file(file_path)
|
28
28
|
valid_paths << file_path
|
29
|
-
rescue
|
29
|
+
rescue StandardError
|
30
30
|
next
|
31
31
|
end
|
32
32
|
end
|
@@ -39,7 +39,7 @@ module PropertyGenerator
|
|
39
39
|
list_of_file_paths.each do |file_path|
|
40
40
|
begin
|
41
41
|
YAML.load_file(file_path)
|
42
|
-
rescue
|
42
|
+
rescue StandardError
|
43
43
|
invalid_paths << file_path
|
44
44
|
end
|
45
45
|
end
|
@@ -57,21 +57,21 @@ module PropertyGenerator
|
|
57
57
|
def writer(service_name, finalized, configs, output_path, additional_options)
|
58
58
|
output = []
|
59
59
|
envs = configs.environments
|
60
|
-
environmental_configs =
|
61
|
-
envs.each do |
|
62
|
-
account = environmental_configs[env][
|
63
|
-
region = environmental_configs[env][
|
64
|
-
hash = {
|
60
|
+
environmental_configs = configs.environment_configs
|
61
|
+
envs.each do |env|
|
62
|
+
account = environmental_configs[env]['account']
|
63
|
+
region = environmental_configs[env]['region']
|
64
|
+
hash = { 'properties' => finalized[env] }
|
65
65
|
['configname', 'stringdata', 'configlabels', 'secretlabels'].each do |setting|
|
66
|
-
hash[setting] = additional_options[setting]
|
66
|
+
hash[setting] = additional_options[setting] unless additional_options[setting].nil?
|
67
67
|
end
|
68
68
|
json = JSON.pretty_generate(hash)
|
69
|
-
#IF users are specifing a vpc then we will drop property files under the dir that corresponds to the vpc
|
70
|
-
if environmental_configs[env].key?(
|
71
|
-
vpc_dir = "#{output_path}/#{account}/#{region}/#{environmental_configs[env][
|
69
|
+
# IF users are specifing a vpc then we will drop property files under the dir that corresponds to the vpc
|
70
|
+
if environmental_configs[env].key?('vpc') && !environmental_configs[env]['vpc'].nil?
|
71
|
+
vpc_dir = "#{output_path}/#{account}/#{region}/#{environmental_configs[env]['vpc']}"
|
72
72
|
FileUtils.mkdir_p("#{vpc_dir}/") unless Dir.exist?(vpc_dir)
|
73
|
-
File.write("#{output_path}/#{account}/#{region}/#{environmental_configs[env][
|
74
|
-
output << "#{output_path}/#{account}/#{region}/#{environmental_configs[env][
|
73
|
+
File.write("#{output_path}/#{account}/#{region}/#{environmental_configs[env]['vpc']}/#{service_name}.json", json)
|
74
|
+
output << "#{output_path}/#{account}/#{region}/#{environmental_configs[env]['vpc']}/#{service_name}.json"
|
75
75
|
else
|
76
76
|
FileUtils.mkdir_p("#{output_path}/#{account}/#{region}/") unless Dir.exist?("#{output_path}/#{account}/#{region}/")
|
77
77
|
File.write("#{output_path}/#{account}/#{region}/#{service_name}.json", json)
|
@@ -83,22 +83,22 @@ module PropertyGenerator
|
|
83
83
|
|
84
84
|
def sync(region, account, bucket, file, file_region)
|
85
85
|
s3 = Aws::S3::Resource.new(region: region)
|
86
|
-
filename = file.split(
|
86
|
+
filename = file.split('/').last
|
87
87
|
puts "Destination: #{account}/#{file_region}/#{filename}"
|
88
88
|
puts "Uploading: #{file}"
|
89
89
|
obj = s3.bucket(bucket).object("#{account}/#{file_region}/#{filename}")
|
90
90
|
obj.upload_file(file)
|
91
91
|
end
|
92
92
|
|
93
|
-
#Force users to specify VPCs for all environments if specified for one environment.
|
94
|
-
#This allows us to skip having conditional logic downstream in CPS requests
|
93
|
+
# Force users to specify VPCs for all environments if specified for one environment.
|
94
|
+
# This allows us to skip having conditional logic downstream in CPS requests
|
95
95
|
def config_enforcer(environment_configs)
|
96
96
|
a_vpc_exists = false
|
97
97
|
environment_configs.each do |environment, config|
|
98
|
-
if config.key?(
|
98
|
+
if config.key?('vpc')
|
99
99
|
a_vpc_exists = true
|
100
100
|
elsif a_vpc_exists
|
101
|
-
raise(
|
101
|
+
raise('If you are using VPCs then a VPC must be specified for all environments in the environment_configs')
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
data/lib/linter/config_linter.rb
CHANGED
@@ -1,50 +1,53 @@
|
|
1
1
|
module PropertyGenerator
|
2
2
|
require 'yaml'
|
3
3
|
class ConfigLinter
|
4
|
+
TESTS = [
|
5
|
+
'config_has_correct_keys',
|
6
|
+
'environment_configs_match_environments_list',
|
7
|
+
'environment_configs_have_valid_region_and_account_values',
|
8
|
+
'environment_configs_have_well_formatted_interpolations',
|
9
|
+
'config_file_is_present'
|
10
|
+
].freeze
|
4
11
|
|
5
12
|
attr_accessor :configs
|
6
13
|
|
7
|
-
def initialize(path)
|
14
|
+
def initialize(path, ignored_tests)
|
8
15
|
@configs = check_for_config(path)
|
16
|
+
@ignored_tests = ignored_tests
|
9
17
|
end
|
10
18
|
|
11
19
|
def run_config_tests
|
12
20
|
if @configs == {}
|
13
21
|
tests = ['config_file_is_present']
|
14
22
|
else
|
15
|
-
tests =
|
16
|
-
'environment_configs_match_environments_list',
|
17
|
-
'environment_configs_have_valid_region_and_account_values',
|
18
|
-
'environment_configs_have_well_formatted_interpolations',
|
19
|
-
'config_file_is_present']
|
23
|
+
tests = TESTS
|
20
24
|
end
|
21
|
-
|
22
|
-
|
25
|
+
tests -= @ignored_tests
|
26
|
+
|
27
|
+
PropertyGenerator.test_runner(self, tests)
|
23
28
|
end
|
24
29
|
|
25
30
|
def check_for_config(path)
|
26
|
-
#Tries to load the config file - if is unable to load config.yml it returns an empty hash
|
27
|
-
#Empty hash is returned so that the rest of the files are still able to be linted instead of stopping at this point.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
31
|
+
# Tries to load the config file - if is unable to load config.yml it returns an empty hash
|
32
|
+
# Empty hash is returned so that the rest of the files are still able to be linted instead of stopping at this point.
|
33
|
+
|
34
|
+
YAML.load_file(path)
|
35
|
+
rescue StandardError
|
36
|
+
{}
|
33
37
|
end
|
34
38
|
|
35
39
|
def config_file_is_present
|
36
|
-
status = {status: 'pass', error: ''}
|
40
|
+
status = { status: 'pass', error: '' }
|
37
41
|
if @configs == {}
|
38
42
|
status[:status] = 'fail'
|
39
|
-
status[:error] =
|
43
|
+
status[:error] = 'Config.yml file is missing, it is required.'
|
40
44
|
end
|
41
45
|
status
|
42
46
|
end
|
43
47
|
|
44
48
|
def config_has_correct_keys
|
45
|
-
status = {status: 'pass', error: ''}
|
46
|
-
config_keys = ['environments', 'accounts',
|
47
|
-
'environment_configs']
|
49
|
+
status = { status: 'pass', error: '' }
|
50
|
+
config_keys = ['environments', 'accounts', 'environment_configs']
|
48
51
|
if @configs.keys != config_keys
|
49
52
|
status[:status] = 'fail'
|
50
53
|
status[:error] = "Config keys should be 'environments', 'accounts', and 'environment_configs'."
|
@@ -53,40 +56,37 @@ module PropertyGenerator
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def environment_configs_match_environments_list
|
56
|
-
status = {status: 'pass', error: ''}
|
59
|
+
status = { status: 'pass', error: '' }
|
57
60
|
if @configs['environments'] != @configs['environment_configs'].keys
|
58
61
|
status[:status] = 'fail'
|
59
|
-
status[:error] =
|
62
|
+
status[:error] = 'Environments in environment_configs do not match environments listed in config environments.'
|
60
63
|
end
|
61
64
|
status
|
62
65
|
end
|
63
66
|
|
64
67
|
def environment_configs_have_valid_region_and_account_values
|
65
|
-
status = {status: 'pass', error: ''}
|
66
|
-
environments_missmatch_values = []
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
if any_missmatches
|
74
|
-
status[:status] = 'fail'
|
75
|
-
status[:error] = "Environments: #{environments_missmatch_values} in environment_configs have a region or account value not listed in top level."
|
76
|
-
end
|
68
|
+
status = { status: 'pass', error: '' }
|
69
|
+
environments_missmatch_values = @configs['environment_configs'].reject do |_, env_config|
|
70
|
+
env_config.key?('region') && @configs['accounts'].include?(env_config['account'])
|
71
|
+
end.keys
|
72
|
+
|
73
|
+
unless environments_missmatch_values.empty?
|
74
|
+
status[:status] = 'fail'
|
75
|
+
status[:error] = "Environments: #{environments_missmatch_values} in environment_configs have a region or account value not listed in top level."
|
77
76
|
end
|
77
|
+
|
78
78
|
status
|
79
79
|
end
|
80
80
|
|
81
81
|
def environment_configs_have_well_formatted_interpolations
|
82
|
-
status = {status: 'pass', error: ''}
|
82
|
+
status = { status: 'pass', error: '' }
|
83
83
|
environments_with_bad_interpolations = []
|
84
84
|
any_mistakes = false
|
85
85
|
@configs['environment_configs'].keys.each do |environment|
|
86
86
|
if @configs['environment_configs'][environment]['interpolations'].class == Hash
|
87
87
|
@configs['environment_configs'][environment]['interpolations'].each do |interpolation, value|
|
88
88
|
if value.class != String && value.class != Integer && value.class != Float && value.class != Fixnum
|
89
|
-
environments_with_bad_interpolations << {environment => interpolation}
|
89
|
+
environments_with_bad_interpolations << { environment => interpolation }
|
90
90
|
any_mistakes = true
|
91
91
|
end
|
92
92
|
end
|
@@ -101,6 +101,5 @@ module PropertyGenerator
|
|
101
101
|
end
|
102
102
|
status
|
103
103
|
end
|
104
|
-
|
105
104
|
end
|
106
105
|
end
|