cps-property-generator 0.2.11 → 0.2.17

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: a336b0ce14011377bc50c3c669993f436fd8e31d
4
- data.tar.gz: e9d5899eae6a9b456e3d53c97d588c7757013503
3
+ metadata.gz: 637bbf0eb6973d4e0a9ba99f1e746e17aa833f3b
4
+ data.tar.gz: 885746737e416ed9c89652e252d82c23efb6aa71
5
5
  SHA512:
6
- metadata.gz: 2a38fe0b448efba004406062b8bdd8736fc44195d94351b07bf1b859e327dcad44b07d194ba778784eeb7f4eee6bc592f6082628abc926a48a5d41357b360868
7
- data.tar.gz: 914944ab88f0e717a9e4231f40ce0eb8806f27de29f7b4d1c61e79eceb05ab5a87c8869e167135ac317052b71cfbe8fa4707b3867bd92c92c80887d55f975282
6
+ metadata.gz: 3e60bf3523a4f77a662d61cf7f18ae941264c2ae6e3ff2f1e19e86f347ccaedabe08fbd05c22df8f0c5768f29b1b34cc44eb7504a6a63a5be71b30bcc355b30c
7
+ data.tar.gz: 20879ea40f9b458f538bde77b9d19703b571cc1bee0aec595909f1aeea5e69cc862adf49221576d8f7b68a2b41d7fd3bd7c7aa5989c54f66fccdddec8168d62d
data/README.md CHANGED
@@ -77,6 +77,21 @@ 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
+ ###### Encrypted Properties in Environment Globals
81
+ 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
+ ```yaml
83
+ property_name_1: value
84
+ property_name_2: value
85
+ encrypted:
86
+ encrypted_property_1:
87
+ $ssm:
88
+ region: region
89
+ encrypted: encrypted_value
90
+ encrypted_property_2:
91
+ $ssm:
92
+ region: region
93
+ encrypted: encrypted_value
94
+ ```
80
95
 
81
96
  ##### Step 3: Creating your service definitions
82
97
  Service definitions have the highest level of supersedence and will overwrite matching global definitions.
@@ -46,10 +46,15 @@ module PropertyGenerator
46
46
  upload_account = config['upload_account']
47
47
  upload_region = config['upload_region']
48
48
  upload_bucket = config['upload_bucket']
49
- out.each do |file|
50
- next unless file.include?("#{upload_account}") && file.include?("#{upload_region}")
51
- file_region = file.split("/")[-2]
52
- PropertyGenerator.sync(upload_region, upload_account, upload_bucket, file, file_region)
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)
53
58
  end
54
59
  end
55
60
 
@@ -41,6 +41,11 @@ module PropertyGenerator
41
41
  @environments.each do |env|
42
42
  next unless File.exists?("#{@project_path}/globals/accounts/#{account}/environments/#{env}.yml")
43
43
  data[account][env] = YAML.load_file("#{@project_path}/globals/accounts/#{account}/environments/#{env}.yml")
44
+ unless data[account][env]['encrypted'].nil?
45
+ encrypted = data[account][env]['encrypted'].dup
46
+ not_encrypted = data[account][env].reject { |k,_| k == 'encrypted' }
47
+ data[account][env] = not_encrypted.merge(encrypted)
48
+ end
44
49
  end
45
50
  end
46
51
  data
@@ -14,7 +14,6 @@ module PropertyGenerator
14
14
 
15
15
  def run_globals_tests
16
16
  tests = ['globals_load_as_hashes',
17
- 'globals_have_no_hashes_as_values',
18
17
  'globals_are_defined_for_valid_environemnts',
19
18
  ]
20
19
  results = PropertyGenerator.test_runner(self, tests)
@@ -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', 'configname', 'stringdata', 'configlabels', 'secretlabels']
51
+ accepted_keys = ['default', 'environments', 'encrypted', 'configname', 'stringdata', 'configlabels', 'secretlabels', 'label']
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', 'encrypted', 'configname', 'stringdata' 'configlabels' or 'secretlabels'"
62
+ status[:error] = "Service files: #{services_with_unacceptable_keys} have keys other than 'default', 'environments', 'encrypted', 'configname', 'stringdata', 'configlabels', 'secretlabels' or 'label'"
63
63
  end
64
64
  status
65
65
  end
@@ -156,7 +156,7 @@ module PropertyGenerator
156
156
 
157
157
  def service_encrypted_fields_are_correct
158
158
  status = {status: 'pass', error: ''}
159
- accepted_keys = ['region', 'encrypted', 'service']
159
+ accepted_keys = ['region', 'encrypted', 'service', 'label']
160
160
  services_with_unacceptable_keys = []
161
161
  @services.each do |path, loaded|
162
162
  if loaded['encrypted'] != nil
@@ -181,7 +181,7 @@ module PropertyGenerator
181
181
  end
182
182
  if services_with_unacceptable_keys != []
183
183
  status[:status] = 'fail'
184
- status[:error] = "Service files: #{services_with_unacceptable_keys} have encrypted properties with bad indentation or keys other than 'region' and 'encrypted'."
184
+ status[:error] = "Service files: #{services_with_unacceptable_keys} have encrypted properties with bad indentation or keys other than 'region', 'encrypted' or 'label'."
185
185
  end
186
186
  status
187
187
  end
@@ -16,11 +16,11 @@ module PropertyGenerator
16
16
  end
17
17
 
18
18
  it 'should read the environment globals' do
19
- expect(global.get_environment_globals).to eq({123456789012=>{'my-test-env1'=>{'my_env'=>'my-test-env1'}}})
19
+ expect(global.get_environment_globals).to eq({123456789012=>{'my-test-env1'=>{'my_env'=>'my-test-env1', 'test_encrypted' => { '$ssm' => { 'region' => 'region', 'encrypted' => 'encrypted_value' }}}}})
20
20
  end
21
21
 
22
22
  it 'should condense the globals accurately' do
23
- expect(global.condense_globals).to eq({'my-test-env1'=>{'foo' => 'bar', 'my_account'=>123456789012, 'my_env'=>'my-test-env1'},
23
+ expect(global.condense_globals).to eq({'my-test-env1'=>{'foo' => 'bar', 'my_account'=>123456789012, 'my_env'=>'my-test-env1', 'test_encrypted' => { '$ssm' => { 'region' => 'region', 'encrypted' => 'encrypted_value' }}},
24
24
  'my-test-env2' => {'foo' => 'bar'}})
25
25
  end
26
26
 
@@ -1,18 +1,19 @@
1
- require 'spec_helper'
2
- require_relative '../../lib/generator/service'
3
- require_relative '../../lib/generator/globals'
4
- require_relative '../../lib/generator/config'
5
- require 'pp'
1
+ require "spec_helper"
2
+ require_relative "../../lib/generator/service"
3
+ require_relative "../../lib/generator/globals"
4
+ require_relative "../../lib/generator/config"
5
+ require "pp"
6
6
  module PropertyGenerator
7
7
  describe Service do
8
8
  subject(:config) {PropertyGenerator::Config.new(File.expand_path("./spec/resources"))}
9
9
  subject(:globals) {PropertyGenerator::Globals.new(File.expand_path("./spec/resources"), config)}
10
- subject(:service) {described_class.new(YAML.load_file('./spec/resources/services/my-microservice-1.yml'), config, globals.globals)}
10
+ subject(:service) {described_class.new(YAML.load_file("./spec/resources/services/my-microservice-1.yml"), config, globals.globals)}
11
11
 
12
- it 'Parses and condenses a service\'s defaults and environment definitions' do
12
+ it "Parses and condenses a service\"s defaults and environment definitions" do
13
13
  expect(service.service).to eq({"my-test-env1"=> {"foo"=>"bar",
14
14
  "my_account"=>123456789012,
15
15
  "my_env"=>"my-test-env1",
16
+ "test_encrypted" => { "$ssm" => { "region" => "region", "encrypted" => "encrypted_value" }},
16
17
  "database.host"=>"my.database.{domain}",
17
18
  "database.port"=>3306},
18
19
  "my-test-env2"=> {"foo"=>"bar",
@@ -20,10 +21,11 @@ module PropertyGenerator
20
21
  "database.port"=>3306}})
21
22
  end
22
23
 
23
- it 'Tests interpolations work for a service' do
24
+ it "Tests interpolations work for a service" do
24
25
  expect(service.interpolate).to eq({"my-test-env1"=> {"foo"=>"bar",
25
26
  "my_account"=>123456789012,
26
27
  "my_env"=>"my-test-env1",
28
+ "test_encrypted" => { "$ssm" => { "region" => "region", "encrypted" => "encrypted_value" }},
27
29
  "database.host"=>"my.database.my1.com",
28
30
  "database.port"=>3306},
29
31
  "my-test-env2"=> {"foo"=>"bar",
@@ -1 +1,6 @@
1
- my_env: 'my-test-env1'
1
+ my_env: 'my-test-env1'
2
+ encrypted:
3
+ test_encrypted:
4
+ $ssm:
5
+ region: region
6
+ encrypted: encrypted_value
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.11
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Call