cps-property-generator 0.2.17 → 0.3.1

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.
@@ -3,33 +3,38 @@ require_relative '../../lib/generator/config'
3
3
 
4
4
  module PropertyGenerator
5
5
  describe Config do
6
- subject(:config) {described_class.new(File.expand_path("./spec/resources"))}
6
+ subject(:config) { described_class.new(File.expand_path('./spec/resources')) }
7
7
 
8
8
  it 'should return the environments' do
9
- expect(config.environments).to eq(['my-test-env1', 'my-test-env2'])
9
+ expect(config.environments).to eq(%w[my-test-env1 my-test-env2])
10
10
  end
11
11
 
12
12
  it 'should return the accounts' do
13
13
  expect(config.accounts).to eq([123456789012, 987654321098])
14
14
  end
15
15
 
16
- #this is gross
16
+ # this is gross
17
17
  it 'should return the environment configs' do
18
- expect(config.environment_configs).to eq({'my-test-env1' => {'region' => 'us-east-1',
19
- 'account' => 123456789012,
20
- 'interpolations' => {'region' => 'us-east-1',
21
- 'cloud' => 'test-cloud-1',
22
- 'domain' => 'my1.com'}
23
- },
24
- 'my-test-env2' => {'region' => 'eu-central-1',
25
- 'account' => 987654321098,
26
- 'interpolations' => {'region' => 'eu-central-1',
27
- 'cloud' => 'test-cloud-2',
28
- 'domain' => 'my2.com'}
29
- }
18
+ expect(config.environment_configs).to eq({
19
+ 'my-test-env1' => {
20
+ 'region' => 'us-east-1',
21
+ 'account' => 123456789012,
22
+ 'interpolations' => {
23
+ 'region' => 'us-east-1',
24
+ 'cloud' => 'test-cloud-1',
25
+ 'domain' => 'my1.com'
26
+ }
27
+ },
28
+ 'my-test-env2' => {
29
+ 'region' => 'eu-central-1',
30
+ 'account' => 987654321098,
31
+ 'interpolations' => {
32
+ 'region' => 'eu-central-1',
33
+ 'cloud' => 'test-cloud-2',
34
+ 'domain' => 'my2.com'
35
+ }
36
+ }
30
37
  })
31
38
  end
32
-
33
-
34
39
  end
35
- end
40
+ end
@@ -1,28 +1,75 @@
1
1
  require 'spec_helper'
2
2
  require_relative '../../lib/generator/globals'
3
3
  require_relative '../../lib/generator/config'
4
+
4
5
  module PropertyGenerator
5
6
  describe Globals do
6
- subject(:config) {PropertyGenerator::Config.new(File.expand_path("./spec/resources"))}
7
+ subject(:config) { PropertyGenerator::Config.new(File.expand_path('./spec/resources')) }
7
8
 
8
- subject(:global) {described_class.new(File.expand_path("./spec/resources"), config)}
9
+ subject(:global) { described_class.new(File.expand_path('./spec/resources'), config) }
9
10
 
10
11
  it 'should read the main global file' do
11
- expect(global.get_main_global).to eq({'foo'=>'bar'})
12
+ expect(global.get_main_global).to eq({
13
+ 'foo' => 'bar',
14
+ 'map' => {
15
+ 'key1' => 'val1',
16
+ 'key2' => 'val2',
17
+ 'key4' => '{domain}'
18
+ }
19
+ })
12
20
  end
13
21
 
14
22
  it 'should read the account globals' do
15
- expect(global.get_account_globals).to eq({123456789012=>{'my_account'=>123456789012}})
23
+ expect(global.get_account_globals).to eq({
24
+ 123456789012 => {
25
+ 'my_account' => 123456789012
26
+ }
27
+ })
16
28
  end
17
29
 
18
30
  it 'should read the environment globals' do
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' }}}}})
31
+ expect(global.get_environment_globals).to eq({
32
+ 123456789012 => {
33
+ 'my-test-env1' => {
34
+ 'my_env' => 'my-test-env1',
35
+ 'test_encrypted' => {
36
+ '$ssm' => {
37
+ 'region' => 'region',
38
+ 'encrypted' => 'encrypted_value'
39
+ }
40
+ }
41
+ }
42
+ }
43
+ })
20
44
  end
21
45
 
22
46
  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', 'test_encrypted' => { '$ssm' => { 'region' => 'region', 'encrypted' => 'encrypted_value' }}},
24
- 'my-test-env2' => {'foo' => 'bar'}})
47
+ expect(global.condense_globals).to eq({
48
+ 'my-test-env1' => {
49
+ 'foo' => 'bar',
50
+ 'map' => {
51
+ 'key1' => 'val1',
52
+ 'key2' => 'val2',
53
+ 'key4' => '{domain}'
54
+ },
55
+ 'my_account' => 123456789012,
56
+ 'my_env' => 'my-test-env1',
57
+ 'test_encrypted' => {
58
+ '$ssm' => {
59
+ 'region' => 'region',
60
+ 'encrypted' => 'encrypted_value'
61
+ }
62
+ }
63
+ },
64
+ 'my-test-env2' => {
65
+ 'foo' => 'bar',
66
+ 'map' => {
67
+ 'key1' => 'val1',
68
+ 'key2' => 'val2',
69
+ 'key4' => '{domain}'
70
+ }
71
+ }
72
+ })
25
73
  end
26
-
27
74
  end
28
- end
75
+ end
@@ -1,37 +1,96 @@
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
+
6
6
  module PropertyGenerator
7
7
  describe Service do
8
- subject(:config) {PropertyGenerator::Config.new(File.expand_path("./spec/resources"))}
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)}
8
+ subject(:config) { PropertyGenerator::Config.new(File.expand_path('./spec/resources')) }
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) }
11
11
 
12
- it "Parses and condenses a service\"s defaults and environment definitions" do
13
- expect(service.service).to eq({"my-test-env1"=> {"foo"=>"bar",
14
- "my_account"=>123456789012,
15
- "my_env"=>"my-test-env1",
16
- "test_encrypted" => { "$ssm" => { "region" => "region", "encrypted" => "encrypted_value" }},
17
- "database.host"=>"my.database.{domain}",
18
- "database.port"=>3306},
19
- "my-test-env2"=> {"foo"=>"bar",
20
- "database.host"=>"my.database.{domain}",
21
- "database.port"=>3306}})
12
+ it "Parses and condenses a service's defaults and environment definitions" do
13
+ expect(service.service).to eq({
14
+ 'my-test-env1' => {
15
+ 'foo' => 'bar',
16
+ 'map' => {
17
+ 'key1' => 'notval1',
18
+ 'key2' => 'val2',
19
+ 'key3' => '{cloud}-{region}',
20
+ 'key4' => '{domain}',
21
+ 'arr' => %w[one two {domain}],
22
+ 'hash' => '2533cc7'
23
+ },
24
+ 'my_account' => 123456789012,
25
+ 'my_env' => 'my-test-env1',
26
+ 'test_encrypted' => {
27
+ '$ssm' => {
28
+ 'region' => 'region',
29
+ 'encrypted' => 'encrypted_value'
30
+ }
31
+ },
32
+ 'database.host' => 'my.database.{domain}',
33
+ 'database.port' => 3306,
34
+ 'thread.pool.size' => 12
35
+ },
36
+ 'my-test-env2' => {
37
+ 'foo' => 'bar',
38
+ 'map' => {
39
+ 'key1' => 'notval1',
40
+ 'key2' => 'val2',
41
+ 'key3' => '{cloud}-{region}',
42
+ 'key4' => '{domain}',
43
+ 'arr' => %w[one two {domain}],
44
+ 'hash' => 'e501c28'
45
+ },
46
+ 'database.host' => 'my.database.{domain}',
47
+ 'database.port' => 3306,
48
+ 'thread.pool.size' => 8,
49
+ 'new_arr' => %w[{region} {cloud} {domain}]
50
+ }
51
+ })
22
52
  end
23
53
 
24
- it "Tests interpolations work for a service" do
25
- expect(service.interpolate).to eq({"my-test-env1"=> {"foo"=>"bar",
26
- "my_account"=>123456789012,
27
- "my_env"=>"my-test-env1",
28
- "test_encrypted" => { "$ssm" => { "region" => "region", "encrypted" => "encrypted_value" }},
29
- "database.host"=>"my.database.my1.com",
30
- "database.port"=>3306},
31
- "my-test-env2"=> {"foo"=>"bar",
32
- "database.host"=>"my.database.my2.com",
33
- "database.port"=>3306}})
54
+ it 'Tests interpolations work for a service' do
55
+ expect(service.interpolate).to eq({
56
+ 'my-test-env1' => {
57
+ 'foo' => 'bar',
58
+ 'map' => {
59
+ 'key1' => 'notval1',
60
+ 'key2' => 'val2',
61
+ 'key3' => 'test-cloud-1-us-east-1',
62
+ 'key4' => 'my1.com',
63
+ 'arr' => %w[one two my1.com],
64
+ 'hash' => '2533cc7'
65
+ },
66
+ 'my_account' => 123456789012,
67
+ 'my_env' => 'my-test-env1',
68
+ 'test_encrypted' => {
69
+ '$ssm' => {
70
+ 'region' => 'region',
71
+ 'encrypted' => 'encrypted_value'
72
+ }
73
+ },
74
+ 'database.host' => 'my.database.my1.com',
75
+ 'database.port' => 3306,
76
+ 'thread.pool.size' => 12
77
+ },
78
+ 'my-test-env2' => {
79
+ 'foo' => 'bar',
80
+ 'map' => {
81
+ 'key1' => 'notval1',
82
+ 'key2' => 'val2',
83
+ 'key3' => 'test-cloud-2-eu-central-1',
84
+ 'key4' => 'my2.com',
85
+ 'arr' => %w[one two my2.com],
86
+ 'hash' => 'e501c28'
87
+ },
88
+ 'database.host' => 'my.database.my2.com',
89
+ 'database.port' => 3306,
90
+ 'thread.pool.size' => 8,
91
+ 'new_arr' => %w[eu-central-1 test-cloud-2 my2.com]
92
+ }
93
+ })
34
94
  end
35
-
36
95
  end
37
- end
96
+ end
@@ -1 +1,5 @@
1
- foo: "bar"
1
+ foo: "bar"
2
+ map:
3
+ key1: val1
4
+ key2: val2
5
+ key4: '{domain}'
@@ -1,16 +1,35 @@
1
+ env1_assets: &env1_assets
2
+ hash: 2533cc7
3
+ env2_assets: &env2_assets
4
+ hash: e501c28
1
5
  default:
2
6
  database.host: 'my.database.{domain}'
3
7
  database.port: 3306
8
+ map:
9
+ key1: notval1
10
+ key3: '{cloud}-{region}'
11
+ arr:
12
+ - one
13
+ - two
14
+ - '{domain}'
4
15
 
5
16
  environments:
6
- my-test-env-1:
17
+ my-test-env1:
7
18
  thread.pool.size: 12
8
- my-test-env-2:
19
+ map:
20
+ <<: *env1_assets
21
+ my-test-env2:
9
22
  thread.pool.size: 8
23
+ map:
24
+ <<: *env2_assets
25
+ new_arr:
26
+ - '{region}'
27
+ - '{cloud}'
28
+ - '{domain}'
10
29
 
11
30
  #encrypted:
12
- # my-test-env-1:
31
+ # my-test-env1:
13
32
  # my.encrypted.property:
14
33
  # $ssm:
15
34
  # region: us-east-1
16
- # encrypted: PRETEND_ENCRYPTED_PROPERTY_CIPHERTEXT
35
+ # encrypted: PRETEND_ENCRYPTED_PROPERTY_CIPHERTEXT
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cps-property-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.17
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Call
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.11.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.11.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: aws-sdk-s3
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.0.0.rc2
27
41
  - !ruby/object:Gem::Dependency
28
- name: thor
42
+ name: terminal-table
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,21 +53,21 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: activesupport
56
+ name: thor
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 4.2.11.1
61
+ version: '0'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 4.2.11.1
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: terminal-table
70
+ name: thor-scmversion
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: thor-scmversion
84
+ name: webrick
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Generates json property files from yaml definitions to be served up by
98
126
  CPS.
99
127
  email: bcall@rapid7.com
@@ -123,7 +151,7 @@ files:
123
151
  - spec/resources/globals/globals.yml
124
152
  - spec/resources/services/my-microservice-1.yml
125
153
  - spec/spec_helper.rb
126
- homepage: http://rubygems.org/gems/cps-property-generator
154
+ homepage: https://rubygems.org/gems/cps-property-generator
127
155
  licenses:
128
156
  - MIT
129
157
  metadata: {}