cps-property-generator 0.2.5 → 0.2.10

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: 20120f86a00ba65b0baba64bb5d61da9eed6eb5d
4
- data.tar.gz: 30816859903c594ad93257ad4b4e65ad3ec460ae
3
+ metadata.gz: e314fd422a95671a8a8b436c13d350cf0c2eb469
4
+ data.tar.gz: 7ca938a07e15d3411b7bcd5e9aed9b13004f4b5e
5
5
  SHA512:
6
- metadata.gz: c9fcc43c61a741fbfdceb4dc1a9054fe0d0b9d1f56c14c7e7cefe4bb18a1a5580c0f0f79dd4673a3f24d577b6a7a16edc0766753abe91ff08bed64f26820d0a4
7
- data.tar.gz: 4b30b89007e03f55bfd570745111a1fb539ab485309ebce5647cfc68436e551bdee78604b733150439ec01d2cc205e075ec0eecb5c02067021e6bd869106b86c
6
+ metadata.gz: d118ae143395ba549dade258fe38dce125a74742f4533407ed3a05e782ca6fffaee5c6791bb98c6c14771bc92a1124ec91de2e5460475572d91b5acd56a01f1d
7
+ data.tar.gz: e8720c045795c043c0f932386cf5d7694f7d50c6ef04d5ed374f1478c6f898b37d5e519cc4f5c7c7eb3b851f670cb4f434e50f045eb99c1d81f7e746f89c56cf
@@ -24,7 +24,6 @@ class GeneratorCLI < ::Thor
24
24
  else
25
25
  generator.upload(out, options)
26
26
  end
27
-
28
27
  end
29
28
  end
30
29
 
@@ -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.configmap_name)
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']
@@ -1,11 +1,16 @@
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']
9
14
  set_service
10
15
  end
11
16
 
@@ -18,6 +23,10 @@ module PropertyGenerator
18
23
  @service
19
24
  end
20
25
 
26
+ def configmap_name
27
+ @configmapname
28
+ end
29
+
21
30
  def interpolate
22
31
  environments = @environments
23
32
  #read in config
@@ -57,7 +66,7 @@ module PropertyGenerator
57
66
  environment_data = data['environments'][env].dup
58
67
  if data['encrypted']
59
68
  encrypted = data['encrypted'][env].dup unless data['encrypted'][env].nil?
60
- environment_data = data['environments'][env].merge(encrypted) unless encrypted.nil?
69
+ environment_data = data['environments'][env].deep_merge(encrypted) unless encrypted.nil?
61
70
  end
62
71
  if default_clone.nil?
63
72
  merged = environment_data
@@ -85,6 +94,6 @@ module PropertyGenerator
85
94
  output
86
95
  end
87
96
 
88
-
89
97
  end
98
+
90
99
  end
@@ -54,24 +54,29 @@ 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, configmap_name)
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
- json = JSON.pretty_generate({"properties" => finalized[env]})
64
+ json = if configmap_name
65
+ JSON.pretty_generate({"properties" => finalized[env],"configname" => configmap_name})
66
+ else
67
+ JSON.pretty_generate({"properties" => finalized[env]})
68
+ end
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"]}"
68
72
  FileUtils.mkdir_p("#{vpc_dir}/") unless Dir.exist?(vpc_dir)
69
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"
70
75
  else
71
76
  FileUtils.mkdir_p("#{output_path}/#{account}/#{region}/") unless Dir.exist?("#{output_path}/#{account}/#{region}/")
72
77
  File.write("#{output_path}/#{account}/#{region}/#{service_name}.json", json)
78
+ output << "#{output_path}/#{account}/#{region}/#{service_name}.json"
73
79
  end
74
- output << "#{output_path}/#{account}/#{region}/#{service_name}.json"
75
80
  end
76
81
  output
77
82
  end
@@ -14,7 +14,7 @@ module PropertyGenerator
14
14
  else
15
15
  tests = ['config_has_correct_keys',
16
16
  'environment_configs_match_environments_list',
17
- 'environment_configs_have_matching_region_and_account_values',
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 environment_configs_have_matching_region_and_account_values
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 @configs['environments'].include?(@configs['environment_configs'][environment]['region']) && @configs['accounts'].include?(@configs['environment_configs'][environment]['account'])
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']
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 'encrypted'."
62
+ status[:error] = "Service files: #{services_with_unacceptable_keys} have keys other than 'default', 'environments', 'encrypted', or 'configname'."
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.5
4
+ version: 0.2.10
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