cps-property-generator 0.1.3 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/linter/report.rb +3 -0
- data/lib/linter/services_linter.rb +37 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b281f19cf05a8397f807f73458ff117d2bc35d64
|
4
|
+
data.tar.gz: 3c01770ee1b94756cbceaff6d2eaf7d4fa5f5e7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9299a43fc3dab393cce28dae5a20559ea49c0b2bb04afef73bb4a6fb3eed5fdc503dc70a6c942154876235ede20b28276e676d0db8988e8fb360d0a117407073
|
7
|
+
data.tar.gz: 8f45f15755f98347eb5e7f3dee8537ea19eedf15a7bfca5d7720f2bc710a56cf3b6de3bf12f97d942fbe26e9edc0b83c243018e346069be36f07834368f6d06e
|
data/README.md
CHANGED
@@ -108,8 +108,10 @@ encrypted:
|
|
108
108
|
###### Adding interpolations
|
109
109
|
An interpolation is a value that will be dynamically substituted during generation with the correct value for the environment being generated. Interpolations are declared in the config for a given environment. Once declared an interpolation can be used in a property definition by referencing it in braces. If we were to reference the domain interpolation from the example config above we would use `{domain}`.
|
110
110
|
|
111
|
+
Note: values that start with an interpolation must be placed in quotes (ex. "{xxx}.xxx.xxx.{xxx}").
|
112
|
+
|
111
113
|
##### Step 4: Generating Your Properties (Using the CLI)
|
112
114
|
The bin directory contains the generator.rb cli. An example of running the cli is below. The `project_path` argument specifies the path to the properties repo we are generating a uploading properties from. You must be able to create a session with s3 to upload.
|
113
115
|
```sh
|
114
116
|
./generator.rb generate --project_path "~/projects/project-properties" --upload true --upload_account "123456789012" --upload_region "us-east-1" --upload_bucket "propertiesbucket.my-cloud.com"
|
115
|
-
```
|
117
|
+
```
|
data/lib/linter/report.rb
CHANGED
@@ -41,6 +41,9 @@ module PropertyGenerator
|
|
41
41
|
end
|
42
42
|
table = Terminal::Table.new :headings => ['Files'], :title => 'Files Failing to Load', :rows => rows, :style => {:width => 200}
|
43
43
|
puts table
|
44
|
+
puts "*****************"
|
45
|
+
puts "Check for property values that start with an interpolated value \nIf the first character of the value is a bracket yaml will fail to load \nPlace the value in quotes"
|
46
|
+
puts "*****************"
|
44
47
|
end
|
45
48
|
|
46
49
|
def make_pass_table
|
@@ -14,6 +14,7 @@ module PropertyGenerator
|
|
14
14
|
|
15
15
|
def run_services_tests
|
16
16
|
tests = ['services_have_accepted_keys',
|
17
|
+
'service_environments_are_not_empty',
|
17
18
|
'service_defaults_have_no_hashes_as_values',
|
18
19
|
'service_environments_match_config_environments',
|
19
20
|
'service_environments_have_no_hashes_as_values',
|
@@ -24,6 +25,25 @@ module PropertyGenerator
|
|
24
25
|
results
|
25
26
|
end
|
26
27
|
|
28
|
+
def service_environments_are_not_empty
|
29
|
+
status = {status: 'pass', error: ''}
|
30
|
+
services_empty_environments = []
|
31
|
+
@services.each do |path, loaded|
|
32
|
+
unless loaded['environments'] == nil
|
33
|
+
loaded['environments'].each do |environments, properties|
|
34
|
+
if properties == nil
|
35
|
+
services_empty_environments << {path => environments}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
if services_empty_environments != []
|
41
|
+
status[:status] = 'fail'
|
42
|
+
status[:error] = "Service files #{services_empty_environments} have empty environments, these should be omitted."
|
43
|
+
end
|
44
|
+
status
|
45
|
+
end
|
46
|
+
|
27
47
|
def services_have_accepted_keys
|
28
48
|
status = {status: 'pass', error: ''}
|
29
49
|
accepted_keys = ['default', 'environments', 'encrypted']
|
@@ -91,9 +111,11 @@ module PropertyGenerator
|
|
91
111
|
@services.each do |path, loaded|
|
92
112
|
unless loaded['environments'] == nil
|
93
113
|
loaded['environments'].each do |environments, properties|
|
94
|
-
properties
|
95
|
-
|
96
|
-
|
114
|
+
unless properties == nil
|
115
|
+
properties.each do |key, value|
|
116
|
+
if value.class == Hash
|
117
|
+
services_with_hashes_in_environments << {path => {environments => key}}
|
118
|
+
end
|
97
119
|
end
|
98
120
|
end
|
99
121
|
end
|
@@ -136,11 +158,17 @@ module PropertyGenerator
|
|
136
158
|
services_with_unacceptable_keys = []
|
137
159
|
@services.each do |path, loaded|
|
138
160
|
if loaded['encrypted'] != nil
|
139
|
-
loaded['encrypted'].each do |environment,
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
161
|
+
loaded['encrypted'].each do |environment, properties|
|
162
|
+
properties.each do |property, value|
|
163
|
+
if value == nil
|
164
|
+
services_with_unacceptable_keys << {path => {environment => property}}
|
165
|
+
else
|
166
|
+
if value['$ssm'] != nil
|
167
|
+
value['$ssm'].keys.each do |key|
|
168
|
+
unless accepted_keys.include?(key)
|
169
|
+
services_with_unacceptable_keys << {path => {environment => property}}
|
170
|
+
end
|
171
|
+
end
|
144
172
|
end
|
145
173
|
end
|
146
174
|
end
|
@@ -149,7 +177,7 @@ module PropertyGenerator
|
|
149
177
|
end
|
150
178
|
if services_with_unacceptable_keys != []
|
151
179
|
status[:status] = 'fail'
|
152
|
-
status[:error] = "Service files: #{services_with_unacceptable_keys} have encrypted properties with keys other than 'region' and 'encrypted'."
|
180
|
+
status[:error] = "Service files: #{services_with_unacceptable_keys} have encrypted properties with bad indentation or keys other than 'region' and 'encrypted'."
|
153
181
|
end
|
154
182
|
status
|
155
183
|
end
|