aws-cfn-compiler 0.9.9 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/aws-cfn-compiler.gemspec +1 -1
- data/lib/aws/cfn/compiler/base.rb +60 -22
- data/lib/aws/cfn/compiler/mixins/compile.rb +23 -4
- data/lib/aws/cfn/compiler/mixins/load.rb +1 -1
- data/lib/aws/cfn/compiler/mixins/parse.rb +8 -2
- data/lib/aws/cfn/compiler/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGMwOGEzN2JlYTE1NjY3MzI1YzIwNTljMTYwZDM1NDBiMzdmOTU2MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODJlNzFmNjhmZjY3YzFkOGE0OTQwNWFkNjM2ZmNmMjU2OWVlNjBjNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGQwZWRmZjYyMzFkZDY0YWVlZWExYmMzZGYyNTc4MDYzZWI3YTc0ZmQ1NzQx
|
10
|
+
MjE1NTY3Nzk0YTAwOTJjODRjZWUwOWY1YWQ4ZmJlYWMwZmZjYWYyYjM0NDFm
|
11
|
+
MWQxMGY2MWNiOGZhNDg2OTk5NzUwMzU5MGI2NzYxZDA0MTg3ZjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmY0NjhlNTdlN2MyOGM3MTljZTE1OWUxZTZjZDE1MjJmZDk2NmQ3M2ZhYzY4
|
14
|
+
ODZhODc0ODgyYjYxZTQ4MTgyNzc3Mzg3NWY5YTUxNzdlOGI3ZWQ2NWMwZjM2
|
15
|
+
NTYxYWQ0ZjgyZDFkMDliNjA4YzMxYjU0YzRmYTQxZjc4ZDc0Mzk=
|
data/aws-cfn-compiler.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'slop'
|
25
25
|
spec.add_dependency 'inifile'
|
26
26
|
spec.add_dependency 'semverse', '>= 1.1.0'
|
27
|
-
spec.add_dependency 'aws-cfn-dsl', '>= 0.9.
|
27
|
+
spec.add_dependency 'aws-cfn-dsl', '>= 0.9.6'
|
28
28
|
spec.add_dependency 'mixlib-cli', '> 0'
|
29
29
|
spec.add_dependency 'dldinternet-mixlib-cli', '>= 0.2.0'
|
30
30
|
spec.add_dependency 'dldinternet-mixlib-logging', '>= 0.4.0'
|
@@ -17,29 +17,37 @@ module Aws
|
|
17
17
|
def initialize
|
18
18
|
super
|
19
19
|
@items = {}
|
20
|
+
@dynamic_items = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def dynamic_item(section,resource,hash)
|
24
|
+
@dynamic_items[section][resource] = hash
|
20
25
|
end
|
21
26
|
|
22
27
|
def validate(compiled)
|
23
28
|
abort! 'No Resources!?' unless compiled['Resources']
|
24
29
|
logStep 'Validating template'
|
25
30
|
|
31
|
+
# --- Parameters ----------------------------------------------------------------------------------------------
|
26
32
|
prms = compiled['Parameters'].keys rescue []
|
27
|
-
compiled['Parameters']
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
if compiled['Parameters']
|
34
|
+
compiled['Parameters'].each do |name,hash|
|
35
|
+
abort! "Parameter #{name} has an invalid compiled block!\n#{hash.ai}" unless hash.is_a?(Hash)
|
36
|
+
if hash['Type']
|
37
|
+
unless %w(String Number CommaDelimitedList).include?(hash['Type'])
|
38
|
+
abort! "Parameter #{name} has an invalid type: #{hash['Type']}"
|
39
|
+
end
|
32
40
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
if hash['Default']
|
42
|
+
unless hash['Default'].is_a?(String)
|
43
|
+
abort! "Parameter #{name} has an invalid default (Must be string): #{hash['Default']}"
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
47
|
+
@logger.info ' Parameters validated'
|
39
48
|
end
|
40
|
-
@logger.info ' Parameters validated'
|
41
49
|
|
42
|
-
#
|
50
|
+
# --- functions ----------------------------------------------------------------------------------------------
|
43
51
|
funs = find_fns(compiled) #.select { |a| !(a =~ /^AWS::/) }
|
44
52
|
|
45
53
|
bad = []
|
@@ -53,19 +61,23 @@ module Aws
|
|
53
61
|
end
|
54
62
|
@logger.info ' Functions validated'
|
55
63
|
|
56
|
-
# Mappings
|
57
|
-
|
64
|
+
# --- Mappings ----------------------------------------------------------------------------------------------
|
65
|
+
mappings = find_maps(compiled)
|
58
66
|
mpgs = compiled['Mappings'].nil? ? [] : compiled['Mappings'].keys
|
59
67
|
names = mpgs # rscs+
|
60
68
|
|
61
|
-
|
69
|
+
maps = {}
|
70
|
+
mappings.each{|m| maps[m[:mapping]] = m[:source] }
|
71
|
+
mapnames = maps.keys
|
72
|
+
net = (mapnames-names)
|
73
|
+
unless net.empty?
|
62
74
|
@logger.error '!!! Unknown mappings !!!'
|
63
|
-
|
64
|
-
@logger.error " #{name}"
|
75
|
+
net.each do |name|
|
76
|
+
@logger.error " #{name} (Location in template: #{maps[name].join('/')})"
|
65
77
|
end
|
66
78
|
abort!
|
67
79
|
end
|
68
|
-
net = (names-
|
80
|
+
net = (names-mapnames)
|
69
81
|
unless net.empty?
|
70
82
|
@logger.warn '!!! Unused mappings !!!'
|
71
83
|
net.each do |name|
|
@@ -74,11 +86,32 @@ module Aws
|
|
74
86
|
end
|
75
87
|
@logger.info ' Mappings validated'
|
76
88
|
|
89
|
+
# --- Conditions ----------------------------------------------------------------------------------------------
|
90
|
+
cond = find_conditions(compiled)
|
91
|
+
cnds = compiled['Conditions'].keys rescue []
|
92
|
+
names = cnds
|
93
|
+
|
94
|
+
net = (cond-names)
|
95
|
+
unless net.empty?
|
96
|
+
@logger.error '!!! Unknown conditions !!!'
|
97
|
+
net.each do |name|
|
98
|
+
@logger.error " #{name}"
|
99
|
+
end
|
100
|
+
abort!
|
101
|
+
end
|
102
|
+
net = (names-cond)
|
103
|
+
unless net.empty?
|
104
|
+
@logger.warn '!!! Unused conditions !!!'
|
105
|
+
net.each do |name|
|
106
|
+
@logger.warn " #{name}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@logger.info ' Conditions validated'
|
110
|
+
|
111
|
+
# --- References ----------------------------------------------------------------------------------------------
|
77
112
|
# Parameters => Resources => Outputs
|
78
113
|
refs = find_refs(compiled).select { |a,_| !(a =~ /^AWS::/) }
|
79
114
|
rscs = compiled['Resources'].keys
|
80
|
-
cnds = compiled['Conditions'].keys rescue []
|
81
|
-
# outs = compiled['Outputs'].keys rescue []
|
82
115
|
names = rscs+prms+cnds
|
83
116
|
|
84
117
|
net = (refs.keys-names)
|
@@ -96,9 +129,9 @@ module Aws
|
|
96
129
|
@logger.warn " #{name}"
|
97
130
|
end
|
98
131
|
end
|
99
|
-
net = (rscs-refs.keys)
|
132
|
+
net = (rscs.sort-refs.keys.sort)
|
100
133
|
unless net.empty?
|
101
|
-
@logger.info '!!!
|
134
|
+
@logger.info '!!! Unreferenced Resources !!!'
|
102
135
|
net.each do |name|
|
103
136
|
@logger.info " #{name}"
|
104
137
|
end
|
@@ -190,7 +223,12 @@ module Aws
|
|
190
223
|
when /json|jts/
|
191
224
|
@spec = JSON.parse(spec)
|
192
225
|
when /yaml|yts/
|
193
|
-
|
226
|
+
begin
|
227
|
+
@spec = YAML.load(spec)
|
228
|
+
rescue Psych::SyntaxError => e
|
229
|
+
i = 0
|
230
|
+
abort! "Error in the template specification: #{e.message}\n#{spec.split(/\n/).map{|l| "#{i+=1}: #{l}"}.join("\n")}"
|
231
|
+
end
|
194
232
|
else
|
195
233
|
abort! "Unsupported file type for specification: #{spec}"
|
196
234
|
end
|
@@ -245,17 +245,36 @@ module Aws
|
|
245
245
|
r
|
246
246
|
end
|
247
247
|
|
248
|
-
def find_maps(hash)
|
248
|
+
def find_maps(hash,source=[])
|
249
249
|
if hash.is_a? Hash
|
250
250
|
hash.keys.collect do |key|
|
251
251
|
if 'Fn::FindInMap' == key
|
252
|
-
hash[key].first
|
252
|
+
{ mapping: hash[key].first, source: source }
|
253
253
|
else
|
254
|
-
find_maps(hash[key])
|
254
|
+
find_maps(hash[key], [ source, key ].flatten!)
|
255
255
|
end
|
256
256
|
end.flatten.compact.uniq
|
257
257
|
elsif hash.is_a? Array
|
258
|
-
hash.collect{|a|
|
258
|
+
hash.collect{|a|
|
259
|
+
find_maps(a,source)}.flatten.compact.uniq
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def find_conditions(hash)
|
264
|
+
if hash.is_a? Hash
|
265
|
+
hash.keys.collect do |key|
|
266
|
+
if 'Condition' == key
|
267
|
+
if hash[key].is_a?(Array)
|
268
|
+
hash[key].first
|
269
|
+
else
|
270
|
+
hash[key]
|
271
|
+
end
|
272
|
+
else
|
273
|
+
find_conditions(hash[key])
|
274
|
+
end
|
275
|
+
end.flatten.compact.uniq
|
276
|
+
elsif hash.is_a? Array
|
277
|
+
hash.collect{|a| find_conditions(a)}.flatten.compact.uniq
|
259
278
|
end
|
260
279
|
end
|
261
280
|
|
@@ -101,7 +101,7 @@ module Aws
|
|
101
101
|
end
|
102
102
|
|
103
103
|
unless File.directory?(path)
|
104
|
-
@logger.error " !! error: Cannot load
|
104
|
+
@logger.error " !! error: Cannot load #{dir}/#{rsrc} with brick path: \n\t#{@config[:brick_path_list].join("\n\t")} \n(started with #{File.join(base, dir)}')"
|
105
105
|
abort!
|
106
106
|
end
|
107
107
|
path
|
@@ -79,6 +79,7 @@ module Aws
|
|
79
79
|
if spec and spec[section]
|
80
80
|
@items ||= {}
|
81
81
|
@items[section] ||= {}
|
82
|
+
@dynamic_items[section] ||= {}
|
82
83
|
get = {}
|
83
84
|
item = {}
|
84
85
|
spec[section].each do |rsrc|
|
@@ -125,7 +126,12 @@ module Aws
|
|
125
126
|
abort! " !! error: #{$!}"
|
126
127
|
end
|
127
128
|
else
|
128
|
-
|
129
|
+
pm = []
|
130
|
+
set.map { |r,f|
|
131
|
+
b = File.basename(f).gsub( %r(\..*?$), '' )
|
132
|
+
pm << b if b.downcase == rsrc.downcase
|
133
|
+
}
|
134
|
+
abort! " !! error: #{section}/#{base} not found! Possible matches: #{pm}"
|
129
135
|
end
|
130
136
|
end
|
131
137
|
item.keys.each { |key|
|
@@ -135,7 +141,7 @@ module Aws
|
|
135
141
|
}
|
136
142
|
@items[section].merge! item
|
137
143
|
|
138
|
-
unless @items[section].keys.count == spec[section].count
|
144
|
+
unless @items[section].keys.count == (spec[section].count + @dynamic_items[section].keys.count)
|
139
145
|
abort! " !! error: Suspect that a #{section} item was missed or not properly named (Brick name and file name mismatch?)! \nRequested: #{spec[section]}\n Found: #{@items[section].keys}"
|
140
146
|
end
|
141
147
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-cfn-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PKinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -106,14 +106,14 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.9.
|
109
|
+
version: 0.9.6
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ! '>='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.9.
|
116
|
+
version: 0.9.6
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: mixlib-cli
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|