cps-property-generator 0.2.20 → 0.3.3

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,50 +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', 'map' => {'key1' => 'val1', 'key2' => 'val2', 'key4' => '{domain}'}})
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'=>{
24
- 'foo' => 'bar',
25
- 'map' => {
26
- 'key1' => 'val1',
27
- 'key2' => 'val2',
28
- 'key4' => '{domain}'
29
- },
30
- 'my_account'=>123456789012,
31
- 'my_env'=>'my-test-env1',
32
- 'test_encrypted' => {
33
- '$ssm' => {
34
- 'region' => 'region',
35
- 'encrypted' => 'encrypted_value'
36
- }
37
- }
38
- },
39
- 'my-test-env2' => {
40
- 'foo' => 'bar',
41
- 'map' => {
42
- 'key1' => 'val1',
43
- 'key2' => 'val2',
44
- 'key4' => '{domain}'
45
- }
46
- }})
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
+ })
47
73
  end
48
-
49
74
  end
50
75
  end
@@ -1,87 +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
12
+ it "Parses and condenses a service's defaults and environment definitions" do
13
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}]
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'
22
23
  },
23
- "my_account" => 123456789012,
24
- "my_env" => "my-test-env1",
25
- "test_encrypted" => {
26
- "$ssm" => {
27
- "region" => "region",
28
- "encrypted" => "encrypted_value"
24
+ 'my_account' => 123456789012,
25
+ 'my_env' => 'my-test-env1',
26
+ 'test_encrypted' => {
27
+ '$ssm' => {
28
+ 'region' => 'region',
29
+ 'encrypted' => 'encrypted_value'
29
30
  }
30
31
  },
31
- "database.host" => "my.database.{domain}",
32
- "database.port" => 3306,
33
- "thread.pool.size" => 12
32
+ 'database.host' => 'my.database.{domain}',
33
+ 'database.port' => 3306,
34
+ 'thread.pool.size' => 12
34
35
  },
35
- "my-test-env2" => {
36
- "foo" => "bar",
37
- "map" => {
38
- "key1" => "notval1",
39
- "key2" => "val2",
40
- "key3" => "{cloud}-{region}",
41
- "key4" => "{domain}",
42
- "arr" => %w[one two {domain}]
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'
43
45
  },
44
- "database.host" => "my.database.{domain}",
45
- "database.port" => 3306,
46
- "thread.pool.size" => 8,
47
- "new_arr" => %w[{region} {cloud} {domain}]
46
+ 'database.host' => 'my.database.{domain}',
47
+ 'database.port' => 3306,
48
+ 'thread.pool.size' => 8,
49
+ 'new_arr' => %w[{region} {cloud} {domain}]
48
50
  }
49
51
  })
50
52
  end
51
53
 
52
- it "Tests interpolations work for a service" do
54
+ it 'Tests interpolations work for a service' do
53
55
  expect(service.interpolate).to eq({
54
- "my-test-env1" => {
55
- "foo" => "bar",
56
- "map" => {
57
- "key1" => "notval1",
58
- "key2" => "val2",
59
- "key3" => "test-cloud-1-us-east-1",
60
- "key4" => "my1.com",
61
- "arr" => %w[one two my1.com]
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
+ }
62
73
  },
63
- "my_account" => 123456789012,
64
- "my_env" => "my-test-env1",
65
- "test_encrypted" => { "$ssm" => { "region" => "region", "encrypted" => "encrypted_value" } },
66
- "database.host" => "my.database.my1.com",
67
- "database.port" => 3306,
68
- "thread.pool.size" => 12
74
+ 'database.host' => 'my.database.my1.com',
75
+ 'database.port' => 3306,
76
+ 'thread.pool.size' => 12
69
77
  },
70
- "my-test-env2" => {
71
- "foo" => "bar",
72
- "map" => {
73
- "key1" => "notval1",
74
- "key2" => "val2",
75
- "key3" => "test-cloud-2-eu-central-1",
76
- "key4" => "my2.com",
77
- "arr" => %w[one two my2.com]
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'
78
87
  },
79
- "database.host" => "my.database.my2.com",
80
- "database.port" => 3306,
81
- "thread.pool.size" => 8,
82
- "new_arr" => %w[eu-central-1 test-cloud-2 my2.com]
83
- } })
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
+ })
84
94
  end
85
-
86
95
  end
87
96
  end
@@ -1,3 +1,7 @@
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
@@ -12,8 +16,12 @@ default:
12
16
  environments:
13
17
  my-test-env1:
14
18
  thread.pool.size: 12
19
+ map:
20
+ <<: *env1_assets
15
21
  my-test-env2:
16
22
  thread.pool.size: 8
23
+ map:
24
+ <<: *env2_assets
17
25
  new_arr:
18
26
  - '{region}'
19
27
  - '{cloud}'
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.20
4
+ version: 0.3.3
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-06-30 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
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.0.0.rc2
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: thor
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -39,21 +67,21 @@ dependencies:
39
67
  - !ruby/object:Gem::Version
40
68
  version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
- name: activesupport
70
+ name: thor-scmversion
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: 4.2.11.1
75
+ version: '0'
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: 4.2.11.1
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: terminal-table
84
+ name: webrick
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -67,7 +95,7 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
- name: thor-scmversion
98
+ name: rexml
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -94,6 +122,20 @@ dependencies:
94
122
  - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
97
139
  description: Generates json property files from yaml definitions to be served up by
98
140
  CPS.
99
141
  email: bcall@rapid7.com
@@ -123,7 +165,7 @@ files:
123
165
  - spec/resources/globals/globals.yml
124
166
  - spec/resources/services/my-microservice-1.yml
125
167
  - spec/spec_helper.rb
126
- homepage: http://rubygems.org/gems/cps-property-generator
168
+ homepage: https://rubygems.org/gems/cps-property-generator
127
169
  licenses:
128
170
  - MIT
129
171
  metadata: {}