cfn-model 0.4.15 → 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea0ce4fe023541429f2281bf73a25427e4f7f8e38699d813538c94fd9eb7f99
4
- data.tar.gz: ccc58faba8de9f7a2888aa77193416866cfd0cecd1e1e9facb4a84aa221ae42a
3
+ metadata.gz: 645b4009b868ee8aeef8d4f5f7e1d4958305f952249f1c1450f18f4f537676c1
4
+ data.tar.gz: 9a7f7e8ed5b94bd9d18ae836e21bcd3444d23e6d6add7a0d630f09a774a91cea
5
5
  SHA512:
6
- metadata.gz: 6edea6eae9a57f283b7915af1d3d74632990c210a95e403a9a4551eb30fd05be1613a6d8cdb83bcbb683de706150b86776d22c14cbe455b43770e38c79a250c7
7
- data.tar.gz: 10dad014790492293112026e502741e81fb575cbd19a9f4735757ad6b9077532c3a8bef0eafbc55af32aa585cd646f7f6ef3f5fac3de83997ffe1e6e9623e574
6
+ metadata.gz: 9ddca0a63881b9dc1e3baa91ee708fa9ce4a74eaa84239f51c1897042754d3474dcd37ee1dafe6f127967fada9f0c0d8566956e3a0b70464565fcc1a4a540071
7
+ data.tar.gz: 782787b5d721813e99f03c4a9e04b1d71f4cf68115d5d0f1d094e6506e734cfce2c6b6dc58d1edef521c330d6f66bf9b3c38e98d78302ab324f5a69c1a1a50ea
@@ -3,7 +3,7 @@
3
3
  require_relative 'references'
4
4
 
5
5
  class CfnModel
6
- attr_reader :resources, :parameters, :line_numbers, :conditions
6
+ attr_reader :resources, :parameters, :line_numbers, :conditions, :globals
7
7
 
8
8
  ##
9
9
  # if you really want it, here it is - the raw Hash from YAML.load. you'll have to mess with structural nits of
@@ -15,6 +15,7 @@ class CfnModel
15
15
  @parameters = {}
16
16
  @resources = {}
17
17
  @conditions = {}
18
+ @globals = {}
18
19
  @raw_model = nil
19
20
  @line_numbers = {}
20
21
  end
@@ -28,6 +29,9 @@ class CfnModel
28
29
  @conditions.each do |k,v|
29
30
  new_cfn_model.conditions[k] = v
30
31
  end
32
+ @globals.each do |k,v|
33
+ new_cfn_model.globals[k] = v
34
+ end
31
35
  @parameters.each do |k,v|
32
36
  new_cfn_model.parameters[k] = v
33
37
  end
@@ -83,6 +83,7 @@ class CfnParser
83
83
  transform_hash_into_model_elements cfn_hash, cfn_model
84
84
  end
85
85
  transform_hash_into_parameters cfn_hash, cfn_model
86
+ transform_hash_into_globals cfn_hash, cfn_model
86
87
 
87
88
  # pass 2: tie together separate resources only where necessary to make life easier for rule logic
88
89
  post_process_resource_model_elements cfn_model
@@ -182,6 +183,22 @@ class CfnParser
182
183
  cfn_model
183
184
  end
184
185
 
186
+ def transform_hash_into_globals(cfn_hash, cfn_model)
187
+ return cfn_model unless cfn_hash.key?('Globals')
188
+
189
+ cfn_hash['Globals'].each do |resource, parameter_hash|
190
+ global = Parameter.new
191
+ global.id = resource
192
+
193
+ parameter_hash.each do |property_name, property_value|
194
+ global.send("#{map_property_name_to_attribute(property_name)}=", property_value)
195
+ end
196
+
197
+ cfn_model.globals[resource] = global
198
+ end
199
+ cfn_model
200
+ end
201
+
185
202
  def pre_validate_model(cloudformation_yml)
186
203
  errors = CloudFormationValidator.new.validate cloudformation_yml
187
204
  if !errors.nil? && !errors.empty?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfn-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.15
4
+ version: 0.4.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kascic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop