cps-property-generator 0.2.21 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cps-property-generator +3 -5
- data/lib/generator/config.rb +1 -2
- data/lib/generator/generator.rb +7 -9
- 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 +27 -13
data/spec/lib/config_spec.rb
CHANGED
@@ -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(
|
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([
|
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({
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
data/spec/lib/global_spec.rb
CHANGED
@@ -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(
|
7
|
+
subject(:config) { PropertyGenerator::Config.new(File.expand_path('./spec/resources')) }
|
7
8
|
|
8
|
-
subject(:global) {described_class.new(File.expand_path(
|
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({
|
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({
|
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({
|
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({
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
data/spec/lib/service_spec.rb
CHANGED
@@ -1,87 +1,96 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
|
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(
|
9
|
-
subject(:globals) { PropertyGenerator::Globals.new(File.expand_path(
|
10
|
-
subject(:service) { described_class.new(YAML.load_file(
|
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
|
12
|
+
it "Parses and condenses a service's defaults and environment definitions" do
|
13
13
|
expect(service.service).to eq({
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
32
|
+
'database.host' => 'my.database.{domain}',
|
33
|
+
'database.port' => 3306,
|
34
|
+
'thread.pool.size' => 12
|
34
35
|
},
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
54
|
+
it 'Tests interpolations work for a service' do
|
53
55
|
expect(service.interpolate).to eq({
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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'
|
78
87
|
},
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Call
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-11 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:
|
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:
|
56
|
+
name: thor
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
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:
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: thor-scmversion
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -67,13 +81,13 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
|
-
type: :
|
90
|
+
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: rubocop
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -123,7 +137,7 @@ files:
|
|
123
137
|
- spec/resources/globals/globals.yml
|
124
138
|
- spec/resources/services/my-microservice-1.yml
|
125
139
|
- spec/spec_helper.rb
|
126
|
-
homepage:
|
140
|
+
homepage: https://rubygems.org/gems/cps-property-generator
|
127
141
|
licenses:
|
128
142
|
- MIT
|
129
143
|
metadata: {}
|