cps-property-generator 0.1.3 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fce8ef7e8df921058c7b72092dc89348196599b
4
- data.tar.gz: 157741d0aad0f3c2899c00eaedcf2bd6de191a80
3
+ metadata.gz: b281f19cf05a8397f807f73458ff117d2bc35d64
4
+ data.tar.gz: 3c01770ee1b94756cbceaff6d2eaf7d4fa5f5e7a
5
5
  SHA512:
6
- metadata.gz: fa0ec62cb6bbc64ce80a9d19def8851d6e8587b6e7ccf17d455e95577d9daab69285c5cd1e2883c5cb25cb52a11c647b275f62ccfd9bf385ef4366a2760550ae
7
- data.tar.gz: 225a82358e08c2df7136def8ac3a8fefaacc1260b97ec1a1c74c2f90323f3e06adfaa6d6dfeb16f7a36afe2a782f5896ed5e93dcdf47317746e2a5801bfaaf67
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
+ ```
@@ -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.each do |key, value|
95
- if value.class == Hash
96
- services_with_hashes_in_environments << {path => {environments => key}}
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, property|
140
- if loaded['encrypted'][environment][property] != nil
141
- loaded['encrypted'][environment][property].each do |ssm, keys|
142
- unless loaded['encrypted'][environment][property]['$ssm'][keys].keys == accepted_keys
143
- services_with_unacceptable_keys << {path => {environment => property}}
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cps-property-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Call