cfn-model 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cfn_parse +8 -0
- data/lib/cfn-model/model/cfn_model.rb +4 -0
- data/lib/cfn-model/model/model_element.rb +4 -0
- data/lib/cfn-model/parser/cfn_parser.rb +24 -10
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8359965fbd16f4f35a8a964cac9099103f804807
|
4
|
+
data.tar.gz: ca74df177c111002208e3761c91bc894db4e76c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b76b6ca51d85a5f2e26ce1adbfff298c5ae324f89dec122598c8856e0e71a100c44b264567a8643ff8da124bb5b197415e099d20ea8c629e8fd581f266826d
|
7
|
+
data.tar.gz: 0c22a703224333c092f5bc0d3dee14a75980a4daa200f15c60b0351ea124f453c68d8a89c0a3a533077fd416a8c4994e2ae35fae4b1b4df42c0dc6afaa691a88
|
data/bin/cfn_parse
ADDED
@@ -12,9 +12,12 @@ Dir["#{__dir__}/../model/*.rb"].each { |model| require "cfn-model/model/#{File.b
|
|
12
12
|
#
|
13
13
|
class CfnParser
|
14
14
|
# this will convert any !Ref or !GetAtt into tranditional hash like in json
|
15
|
-
YAML.add_domain_type('', 'GetAtt') { |type, val| { 'Fn::GetAtt' => val } }
|
16
15
|
YAML.add_domain_type('', 'Ref') { |type, val| { 'Ref' => val } }
|
17
16
|
|
17
|
+
%w(GetAtt Join Base64 Sub Split Select ImportValue GetAZs FindInMap And Or If Not).each do |function_name|
|
18
|
+
YAML.add_domain_type('', function_name) { |type, val| { "Fn::#{function_name}" => val } }
|
19
|
+
end
|
20
|
+
|
18
21
|
##
|
19
22
|
# Given raw json/yml CloudFormation template, returns a CfnModel object
|
20
23
|
# or raise ParserErrors if something is amiss with the format
|
@@ -92,21 +95,32 @@ class CfnParser
|
|
92
95
|
resource_class = Object.const_get type_name, inherit=false
|
93
96
|
rescue NameError
|
94
97
|
# puts "Never seen class: #{type_name} so going dynamic"
|
95
|
-
resource_class =
|
98
|
+
resource_class = generate_resource_class_from_type type_name
|
99
|
+
end
|
100
|
+
resource_class
|
101
|
+
end
|
96
102
|
|
103
|
+
def initial_lower(str)
|
104
|
+
str.slice(0).downcase + str[1..(str.length)]
|
105
|
+
end
|
106
|
+
|
107
|
+
def generate_resource_class_from_type(type_name)
|
108
|
+
resource_class = Class.new(DynamicModelElement)
|
109
|
+
|
110
|
+
module_names = type_name.split('::')
|
111
|
+
if module_names.first == 'Custom'
|
112
|
+
Object.const_set(module_names[1], resource_class)
|
113
|
+
elsif module_names.first == 'AWS'
|
97
114
|
begin
|
98
|
-
module_constant = AWS.const_get(
|
115
|
+
module_constant = AWS.const_get(module_names[1])
|
99
116
|
rescue NameError
|
100
117
|
module_constant = Module.new
|
101
|
-
module_constant.const_set(
|
118
|
+
module_constant.const_set(module_names[1], module_constant)
|
102
119
|
end
|
103
|
-
|
104
|
-
|
120
|
+
module_constant.const_set(module_names[2], resource_class)
|
121
|
+
else
|
122
|
+
raise "Unknown namespace in resource type: #{module_names.first}"
|
105
123
|
end
|
106
124
|
resource_class
|
107
125
|
end
|
108
|
-
|
109
|
-
def initial_lower(str)
|
110
|
-
str.slice(0).downcase + str[1..(str.length)]
|
111
|
-
end
|
112
126
|
end
|
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kwalify
|
@@ -26,10 +26,12 @@ dependencies:
|
|
26
26
|
version: 0.7.2
|
27
27
|
description: An object model for CloudFormation templates
|
28
28
|
email:
|
29
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- cfn_parse
|
30
31
|
extensions: []
|
31
32
|
extra_rdoc_files: []
|
32
33
|
files:
|
34
|
+
- bin/cfn_parse
|
33
35
|
- lib/cfn-model.rb
|
34
36
|
- lib/cfn-model/model/bucket_policy.rb
|
35
37
|
- lib/cfn-model/model/cfn_model.rb
|