cps-property-generator 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +115 -0
- data/bin/cps-property-generator +45 -0
- data/lib/generator/config.rb +32 -0
- data/lib/generator/generator.rb +50 -0
- data/lib/generator/globals.rb +85 -0
- data/lib/generator/service.rb +89 -0
- data/lib/helpers/helpers.rb +81 -0
- data/lib/linter/config_linter.rb +106 -0
- data/lib/linter/globals_linter.rb +84 -0
- data/lib/linter/linter.rb +35 -0
- data/lib/linter/report.rb +76 -0
- data/lib/linter/services_linter.rb +186 -0
- data/spec/lib/config_spec.rb +35 -0
- data/spec/lib/global_spec.rb +28 -0
- data/spec/lib/service_spec.rb +35 -0
- data/spec/resources/config/config.yml +23 -0
- data/spec/resources/globals/accounts/123456789012/123456789012.yml +1 -0
- data/spec/resources/globals/accounts/123456789012/environments/my-test-env1.yml +1 -0
- data/spec/resources/globals/globals.yml +1 -0
- data/spec/resources/services/my-microservice-1.yml +16 -0
- data/spec/spec_helper.rb +85 -0
- metadata +136 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/generator/config'
|
3
|
+
|
4
|
+
module PropertyGenerator
|
5
|
+
describe Config do
|
6
|
+
subject(:config) {described_class.new(File.expand_path("./spec/resources"))}
|
7
|
+
|
8
|
+
it 'should return the environments' do
|
9
|
+
expect(config.environments).to eq(['my-test-env1', 'my-test-env2'])
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return the accounts' do
|
13
|
+
expect(config.accounts).to eq([123456789012, 987654321098])
|
14
|
+
end
|
15
|
+
|
16
|
+
#this is gross
|
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
|
+
}
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/generator/globals'
|
3
|
+
require_relative '../../lib/generator/config'
|
4
|
+
module PropertyGenerator
|
5
|
+
describe Globals do
|
6
|
+
subject(:config) {PropertyGenerator::Config.new(File.expand_path("./spec/resources"))}
|
7
|
+
|
8
|
+
subject(:global) {described_class.new(File.expand_path("./spec/resources"), config)}
|
9
|
+
|
10
|
+
it 'should read the main global file' do
|
11
|
+
expect(global.get_main_global).to eq({'foo'=>'bar'})
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should read the account globals' do
|
15
|
+
expect(global.get_account_globals).to eq({123456789012=>{'my_account'=>123456789012}})
|
16
|
+
end
|
17
|
+
|
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'}}})
|
20
|
+
end
|
21
|
+
|
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'},
|
24
|
+
'my-test-env2' => {'foo' => 'bar'}})
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
module PropertyGenerator
|
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)}
|
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
|
+
"database.host"=>"my.database.{domain}",
|
17
|
+
"database.port"=>3306},
|
18
|
+
"my-test-env2"=> {"foo"=>"bar",
|
19
|
+
"database.host"=>"my.database.{domain}",
|
20
|
+
"database.port"=>3306}})
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Tests interpolations work for a service' do
|
24
|
+
expect(service.interpolate).to eq({"my-test-env1"=> {"foo"=>"bar",
|
25
|
+
"my_account"=>123456789012,
|
26
|
+
"my_env"=>"my-test-env1",
|
27
|
+
"database.host"=>"my.database.my1.com",
|
28
|
+
"database.port"=>3306},
|
29
|
+
"my-test-env2"=> {"foo"=>"bar",
|
30
|
+
"database.host"=>"my.database.my2.com",
|
31
|
+
"database.port"=>3306}})
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
environments:
|
2
|
+
- 'my-test-env1'
|
3
|
+
- 'my-test-env2'
|
4
|
+
|
5
|
+
accounts:
|
6
|
+
- 123456789012
|
7
|
+
- 987654321098
|
8
|
+
|
9
|
+
environment_configs:
|
10
|
+
my-test-env1:
|
11
|
+
region: 'us-east-1'
|
12
|
+
account: 123456789012
|
13
|
+
interpolations:
|
14
|
+
region: 'us-east-1'
|
15
|
+
cloud: 'test-cloud-1'
|
16
|
+
domain: 'my1.com'
|
17
|
+
my-test-env2:
|
18
|
+
region: 'eu-central-1'
|
19
|
+
account: 987654321098
|
20
|
+
interpolations:
|
21
|
+
region: 'eu-central-1'
|
22
|
+
cloud: 'test-cloud-2'
|
23
|
+
domain: 'my2.com'
|
@@ -0,0 +1 @@
|
|
1
|
+
my_account: 123456789012
|
@@ -0,0 +1 @@
|
|
1
|
+
my_env: 'my-test-env1'
|
@@ -0,0 +1 @@
|
|
1
|
+
foo: "bar"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
default:
|
2
|
+
database.host: 'my.database.{domain}'
|
3
|
+
database.port: 3306
|
4
|
+
|
5
|
+
environments:
|
6
|
+
my-test-env-1:
|
7
|
+
thread.pool.size: 12
|
8
|
+
my-test-env-2:
|
9
|
+
thread.pool.size: 8
|
10
|
+
|
11
|
+
#encrypted:
|
12
|
+
# my-test-env-1:
|
13
|
+
# my.encrypted.property:
|
14
|
+
# $ssm:
|
15
|
+
# region: us-east-1
|
16
|
+
# encrypted: PRETEND_ENCRYPTED_PROPERTY_CIPHERTEXT
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
# rspec-expectations config goes here. You can use an alternate
|
3
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
4
|
+
# assertions if you prefer.
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
7
|
+
# and `failure_message` of custom matchers include text for helper methods
|
8
|
+
# defined using `chain`, e.g.:
|
9
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
10
|
+
# # => "be bigger than 2 and smaller than 4"
|
11
|
+
# ...rather than:
|
12
|
+
# # => "be bigger than 2"
|
13
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
14
|
+
end
|
15
|
+
|
16
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
17
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
18
|
+
config.mock_with :rspec do |mocks|
|
19
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
20
|
+
# a real object. This is generally recommended, and will default to
|
21
|
+
# `true` in RSpec 4.
|
22
|
+
mocks.verify_partial_doubles = true
|
23
|
+
end
|
24
|
+
|
25
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
26
|
+
# have no way to turn it off -- the option exists only for backwards
|
27
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
28
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
29
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
30
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
31
|
+
|
32
|
+
# The settings below are suggested to provide a good initial experience
|
33
|
+
# with RSpec, but feel free to customize to your heart's content.
|
34
|
+
=begin
|
35
|
+
# This allows you to limit a spec run to individual examples or groups
|
36
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
37
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
38
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
39
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
40
|
+
config.filter_run_when_matching :focus
|
41
|
+
|
42
|
+
# Allows RSpec to persist some state between runs in order to support
|
43
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
44
|
+
# you configure your source control system to ignore this file.
|
45
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
46
|
+
|
47
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
48
|
+
# recommended. For more details, see:
|
49
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
50
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
51
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
52
|
+
config.disable_monkey_patching!
|
53
|
+
|
54
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
55
|
+
# be too noisy due to issues in dependencies.
|
56
|
+
config.warnings = true
|
57
|
+
|
58
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
59
|
+
# file, and it's useful to allow more verbose output when running an
|
60
|
+
# individual spec file.
|
61
|
+
if config.files_to_run.one?
|
62
|
+
# Use the documentation formatter for detailed output,
|
63
|
+
# unless a formatter has already been configured
|
64
|
+
# (e.g. via a command-line flag).
|
65
|
+
config.default_formatter = "doc"
|
66
|
+
end
|
67
|
+
|
68
|
+
# Print the 10 slowest examples and example groups at the
|
69
|
+
# end of the spec run, to help surface which specs are running
|
70
|
+
# particularly slow.
|
71
|
+
config.profile_examples = 10
|
72
|
+
|
73
|
+
# Run specs in random order to surface order dependencies. If you find an
|
74
|
+
# order dependency and want to debug it, you can fix the order by providing
|
75
|
+
# the seed, which is printed after each run.
|
76
|
+
# --seed 1234
|
77
|
+
config.order = :random
|
78
|
+
|
79
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
80
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
81
|
+
# test failures related to randomization by passing the same `--seed` value
|
82
|
+
# as the one that triggered the failure.
|
83
|
+
Kernel.srand config.seed
|
84
|
+
=end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cps-property-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Call
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-s3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.rc2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0.rc2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor-scmversion
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Generates json property files from yaml definitions to be served up by
|
84
|
+
CPS.
|
85
|
+
email: bcall@rapid7.com
|
86
|
+
executables:
|
87
|
+
- cps-property-generator
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- README.md
|
92
|
+
- bin/cps-property-generator
|
93
|
+
- lib/generator/config.rb
|
94
|
+
- lib/generator/generator.rb
|
95
|
+
- lib/generator/globals.rb
|
96
|
+
- lib/generator/service.rb
|
97
|
+
- lib/helpers/helpers.rb
|
98
|
+
- lib/linter/config_linter.rb
|
99
|
+
- lib/linter/globals_linter.rb
|
100
|
+
- lib/linter/linter.rb
|
101
|
+
- lib/linter/report.rb
|
102
|
+
- lib/linter/services_linter.rb
|
103
|
+
- spec/lib/config_spec.rb
|
104
|
+
- spec/lib/global_spec.rb
|
105
|
+
- spec/lib/service_spec.rb
|
106
|
+
- spec/resources/config/config.yml
|
107
|
+
- spec/resources/globals/accounts/123456789012/123456789012.yml
|
108
|
+
- spec/resources/globals/accounts/123456789012/environments/my-test-env1.yml
|
109
|
+
- spec/resources/globals/globals.yml
|
110
|
+
- spec/resources/services/my-microservice-1.yml
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
homepage: http://rubygems.org/gems/cps-property-generator
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.6.12
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Centralized Property Service json file generator
|
136
|
+
test_files: []
|