aws-cfn-compiler 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +7 -0
- data/aws-cfn-compiler.iml +52 -2
- data/lib/aws/cfn/compiler/base.rb +176 -111
- data/lib/aws/cfn/compiler/main.rb +3 -5
- data/lib/aws/cfn/compiler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmQ4ODM4MjllY2FjYWM4YjUzNDRkODYwMDNiNGZhZWFiNTk5ZGE5Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Zjc3MTdkNmY0MDIyZTNmOWYyOWViMDE2ZTEzOWRmNDk2OTRkZWNkZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmI4NWIwNjU1NjNlODQ2OGMwN2E0Mzc2MTE2OGVmMTExNWViODcwOGU5ZjU1
|
10
|
+
YzA2ZDQ0ZWU1NjYyZjA4NTk4NzhmOGUwZjk0YTlhYTUyNmJmYzlmZjJiNTI1
|
11
|
+
ZWY2ZTY4MWMxZGFmNzcwMzZkNTc4NWVjNWIyYWNiNzk5YTFhMmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmEyZmViZmEzZDRmYmVkNzQ5ZDg0MDZlMDVlYTlmZmFlNmVhNjNlYTMwMThh
|
14
|
+
MGFmYmQ5NWMyNTlmMGViYWQ4MWQ5ZjVkMTViZmZiYzNjYzU2YTZmN2I2Nzcx
|
15
|
+
OTM3ZmVmMGE4NWYzNWNkZDcxODA1MmI4MTZiYmRjNjE1YTgwNmY=
|
data/Gemfile
CHANGED
@@ -4,7 +4,14 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
gem 'cloudformation-ruby-dsl', :path => '../cloudformation-ruby-dsl', :group => :development
|
7
|
+
|
8
|
+
gem 'dldinternet-mixlib-logging', :path => '../dldinternet-mixlib-logging', :group => :development
|
9
|
+
gem 'dldinternet-mixlib-cli', :path => '../dldinternet-mixlib-cli', :group => :development
|
7
10
|
gem 'aws-cfn-dsl', :path => '../aws-cfn-dsl', :group => :development
|
8
11
|
gem 'aws-cfn-decompiler', :path => '../aws-cfn-decompiler', :group => :development
|
12
|
+
gem 'aws-cfn-compiler', :path => '../aws-cfn-compiler', :group => :development
|
13
|
+
gem 'aws-cfn-yats', :path => '../aws-cfn-yats', :group => :development
|
14
|
+
gem 'aws-cfn-stacker', :path => '../aws-cfn-stacker', :group => :development
|
15
|
+
|
9
16
|
gem 'bundler', "~> 1.6", :group => :development
|
10
17
|
gem 'rake', :group => :development
|
data/aws-cfn-compiler.iml
CHANGED
@@ -10,12 +10,62 @@
|
|
10
10
|
<orderEntry type="sourceFolder" forTests="false" />
|
11
11
|
<orderEntry type="module" module-name="aws-cfn-decompiler" />
|
12
12
|
<orderEntry type="module" module-name="aws-cfn-dsl" />
|
13
|
+
<orderEntry type="module-library">
|
14
|
+
<library name="aws-cfn-stacker (v[path], /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/aws-cfn-stacker) [path][gem]">
|
15
|
+
<CLASSES>
|
16
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
|
17
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
|
18
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
|
19
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
|
20
|
+
</CLASSES>
|
21
|
+
<JAVADOC />
|
22
|
+
<SOURCES>
|
23
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/bin" />
|
24
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/lib" />
|
25
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/pkg" />
|
26
|
+
<root url="file://$MODULE_DIR$/../aws-cfn-stacker/.idea" />
|
27
|
+
</SOURCES>
|
28
|
+
</library>
|
29
|
+
</orderEntry>
|
30
|
+
<orderEntry type="module" module-name="aws-cfn-yats" />
|
13
31
|
<orderEntry type="module" module-name="cloudformation-ruby-dsl" />
|
32
|
+
<orderEntry type="module-library">
|
33
|
+
<library name="dldinternet-mixlib-cli (v0.1.0, /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/dldinternet-mixlib-cli) [path][gem]">
|
34
|
+
<CLASSES>
|
35
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/bin" />
|
36
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/lib" />
|
37
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/pkg" />
|
38
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/.idea" />
|
39
|
+
</CLASSES>
|
40
|
+
<JAVADOC />
|
41
|
+
<SOURCES>
|
42
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/bin" />
|
43
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/lib" />
|
44
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/pkg" />
|
45
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-cli/.idea" />
|
46
|
+
</SOURCES>
|
47
|
+
</library>
|
48
|
+
</orderEntry>
|
49
|
+
<orderEntry type="module-library">
|
50
|
+
<library name="dldinternet-mixlib-logging (v0.2.0, /Users/cdelange/Dropbox/DLDInternet/ws/gems-ws/dldinternet-mixlib-logging) [path][gem]">
|
51
|
+
<CLASSES>
|
52
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/bin" />
|
53
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/lib" />
|
54
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/pkg" />
|
55
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/.idea" />
|
56
|
+
</CLASSES>
|
57
|
+
<JAVADOC />
|
58
|
+
<SOURCES>
|
59
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/bin" />
|
60
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/lib" />
|
61
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/pkg" />
|
62
|
+
<root url="file://$MODULE_DIR$/../dldinternet-mixlib-logging/.idea" />
|
63
|
+
</SOURCES>
|
64
|
+
</library>
|
65
|
+
</orderEntry>
|
14
66
|
<orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
15
67
|
<orderEntry type="library" scope="PROVIDED" name="colorize (v0.7.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
16
68
|
<orderEntry type="library" scope="PROVIDED" name="detabulator (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="dldinternet-mixlib-cli (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="dldinternet-mixlib-logging (v0.1.6, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
19
69
|
<orderEntry type="library" scope="PROVIDED" name="inifile (v2.0.2, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
20
70
|
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
21
71
|
<orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
@@ -3,33 +3,25 @@ require 'json'
|
|
3
3
|
require 'ap'
|
4
4
|
require 'yaml'
|
5
5
|
require 'slop'
|
6
|
+
require 'aws/cfn/dsl/base'
|
6
7
|
require 'aws/cfn/dsl/template'
|
7
8
|
|
8
9
|
module Aws
|
9
10
|
module Cfn
|
10
11
|
module Compiler
|
11
|
-
class Base
|
12
|
+
class Base < Aws::Cfn::Dsl::Base
|
12
13
|
attr_accessor :items
|
13
14
|
attr_accessor :opts
|
14
15
|
attr_accessor :spec
|
15
16
|
|
16
|
-
require 'dldinternet/mixlib/logging'
|
17
|
-
include DLDInternet::Mixlib::Logging
|
18
|
-
|
19
17
|
def initialize
|
18
|
+
super
|
20
19
|
@items = {}
|
21
|
-
@config ||= {}
|
22
|
-
@config[:log_opts] = lambda{|mlll| {
|
23
|
-
:pattern => "%#{mlll}l: %m %C\n",
|
24
|
-
:date_pattern => '%Y-%m-%d %H:%M:%S',
|
25
|
-
}
|
26
|
-
}
|
27
|
-
@config[:log_level] = :step
|
28
|
-
@logger = getLogger(@config)
|
29
20
|
end
|
30
21
|
|
31
22
|
def validate(compiled)
|
32
|
-
|
23
|
+
abort! 'No Resources!?' unless compiled['Resources']
|
24
|
+
logStep 'Validating compiled file...'
|
33
25
|
|
34
26
|
# Mappings => Resources
|
35
27
|
maps = find_maps(compiled) #.select { |a| !(a =~ /^AWS::/) }
|
@@ -44,9 +36,9 @@ module Aws
|
|
44
36
|
end
|
45
37
|
abort!
|
46
38
|
end
|
47
|
-
@logger.
|
39
|
+
@logger.info ' Mappings validated'
|
48
40
|
|
49
|
-
# Parameters => Resources =>
|
41
|
+
# Parameters => Resources => Outputs
|
50
42
|
refs = find_refs(compiled).select { |a,_| !(a =~ /^AWS::/) }
|
51
43
|
prms = compiled['Parameters'].keys rescue []
|
52
44
|
# outs = compiled['Outputs'].keys rescue []
|
@@ -59,12 +51,12 @@ module Aws
|
|
59
51
|
end
|
60
52
|
abort!
|
61
53
|
end
|
62
|
-
@logger.
|
54
|
+
@logger.info ' References validated'
|
63
55
|
end
|
64
56
|
|
65
|
-
def save(compiled
|
66
|
-
output_file = File.expand_path(output_file) if @config[:expandedpaths]
|
67
|
-
|
57
|
+
def save(output_file,compiled)
|
58
|
+
output_file = File.realpath(File.expand_path(output_file)) if @config[:expandedpaths]
|
59
|
+
logStep "Writing compiled file to #{output_file}..."
|
68
60
|
begin
|
69
61
|
hash = {}
|
70
62
|
compiled.each do |item,value|
|
@@ -78,7 +70,7 @@ module Aws
|
|
78
70
|
File.open output_file, 'w' do |f|
|
79
71
|
f.write JSON.pretty_generate(hash, { indent: "\t", space: ' '})
|
80
72
|
end
|
81
|
-
@logger.
|
73
|
+
@logger.info ' Compiled file written.'
|
82
74
|
rescue
|
83
75
|
@logger.error "!!! Could not write compiled file: #{$!}"
|
84
76
|
abort!
|
@@ -87,18 +79,23 @@ module Aws
|
|
87
79
|
|
88
80
|
def load(spec=nil)
|
89
81
|
if spec
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
abs = File.
|
82
|
+
abs = nil
|
83
|
+
[spec, File.join(@opts[:directory],spec)].each do |p|
|
84
|
+
begin
|
85
|
+
abs = File.realpath(File.absolute_path(File.expand_path(p)))
|
86
|
+
break if File.exists?(abs)
|
87
|
+
rescue => e
|
88
|
+
@logger.error e
|
89
|
+
# pass
|
94
90
|
end
|
95
|
-
rescue
|
96
|
-
# pass
|
97
91
|
end
|
92
|
+
|
98
93
|
if File.exists?(abs)
|
99
|
-
|
94
|
+
logStep "Loading specification #{@opts[:expandedpaths] ? abs : spec}..."
|
95
|
+
unless abs =~ /\.(json|ya?ml|jts|yts)\z/i
|
96
|
+
abort! "Unsupported specification file type: #{spec}=>#{abs}\n\tSupported types are: json,yaml,jts,yts\n"
|
97
|
+
end
|
100
98
|
|
101
|
-
@logger.step "Loading specification #{abs}..."
|
102
99
|
spec = File.read(abs)
|
103
100
|
|
104
101
|
case File.extname(File.basename(abs)).downcase
|
@@ -107,11 +104,10 @@ module Aws
|
|
107
104
|
when /yaml|yts/
|
108
105
|
@spec = YAML.load(spec)
|
109
106
|
else
|
110
|
-
|
107
|
+
abort! "Unsupported file type for specification: #{spec}"
|
111
108
|
end
|
112
|
-
# @spec = spec
|
113
109
|
else
|
114
|
-
|
110
|
+
abort! "Unable to open specification: #{abs}"
|
115
111
|
end
|
116
112
|
@dsl ||= Aws::Cfn::Dsl::Template.new(@opts[:directory])
|
117
113
|
%w( Mappings Parameters Resources Outputs ).each do |dir|
|
@@ -124,9 +120,93 @@ module Aws
|
|
124
120
|
|
125
121
|
protected
|
126
122
|
|
127
|
-
|
128
|
-
|
129
|
-
|
123
|
+
# noinspection RubyGlobalVariableNamingConvention
|
124
|
+
def load_dir(dir,spec=nil)
|
125
|
+
logStep "Loading #{dir}..."
|
126
|
+
|
127
|
+
if spec and spec[dir]
|
128
|
+
raise "No such directory: #{@opts[:directory]}" unless File.directory?(@opts[:directory])
|
129
|
+
path = vet_path(dir)
|
130
|
+
@items ||= {}
|
131
|
+
@items[dir] ||= {}
|
132
|
+
set = {}
|
133
|
+
get = {}
|
134
|
+
get[path] = get_file_set([".*"], path, @config[:precedence])
|
135
|
+
|
136
|
+
item = {}
|
137
|
+
spec[dir].each do |rsrc|
|
138
|
+
@logger.info "\tUsing #{dir}/#{rsrc}"
|
139
|
+
set = get[path]
|
140
|
+
refp,sub,base,rel = map_resource_reference(rsrc)
|
141
|
+
unless refp.nil?
|
142
|
+
path = vet_path(sub ? sub : dir,refp, rel)
|
143
|
+
unless get[path]
|
144
|
+
get[path] = get_file_set([".*"], path, @config[:precedence])
|
145
|
+
set = get[path]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
if set[base]
|
149
|
+
if item.has_key?(base)
|
150
|
+
@logger.error " !! error: Duplicate item: #{dir}/#{base}"
|
151
|
+
abort!
|
152
|
+
end
|
153
|
+
|
154
|
+
filename = set[base]
|
155
|
+
unless filename =~ /\.(ru?by?|ya?ml|js(|on))\z/i
|
156
|
+
@logger.info "Brick not supported/ relevant: #{filename}"
|
157
|
+
next
|
158
|
+
end
|
159
|
+
|
160
|
+
begin
|
161
|
+
@logger.debug " reading #{filename}"
|
162
|
+
content = File.read(filename)
|
163
|
+
next if content.size==0
|
164
|
+
|
165
|
+
if filename =~ /\.(rb|ruby)\z/i
|
166
|
+
$Aws_Cfn_Compiler ||= {}
|
167
|
+
$Aws_Cfn_Compiler[dir] ||= {}
|
168
|
+
$Aws_Cfn_Compiler[dir][base] ||= {
|
169
|
+
brick_path: @opts[:directory],
|
170
|
+
template: @dsl,
|
171
|
+
logger: @logger
|
172
|
+
}
|
173
|
+
source_file = File.expand_path(filename)
|
174
|
+
eval "require source_file", binding
|
175
|
+
unless @dsl.dict[dir.to_sym]
|
176
|
+
raise "Unable to expand #{filename} for #{dir}/#{base}"
|
177
|
+
end
|
178
|
+
item.merge! @dsl.dict[dir.to_sym]
|
179
|
+
elsif filename =~ /\.js(|on)\z/i
|
180
|
+
item.merge! JSON.parse(content)
|
181
|
+
elsif filename =~ /\.ya?ml\z/i
|
182
|
+
item.merge! YAML.load(content)
|
183
|
+
else
|
184
|
+
next
|
185
|
+
end
|
186
|
+
|
187
|
+
rescue
|
188
|
+
@logger.error " !! error: #{$!}"
|
189
|
+
abort!
|
190
|
+
end
|
191
|
+
else
|
192
|
+
@logger.error " !! error: #{dir}/#{base} not found!"
|
193
|
+
abort!
|
194
|
+
end
|
195
|
+
end
|
196
|
+
item.keys.each { |key|
|
197
|
+
if @items[dir].has_key?(key)
|
198
|
+
@logger.error " !! error: Duplicate item: #{dir}/#{key}"
|
199
|
+
abort!
|
200
|
+
end
|
201
|
+
}
|
202
|
+
@items[dir].merge! item
|
203
|
+
|
204
|
+
unless @items[dir].keys.count == spec[dir].count
|
205
|
+
@logger.error " !! error: Suspect that a #{dir} item was missed! \nRequested: #{spec[dir]}\n Found: #{@items[dir].keys}"
|
206
|
+
abort!
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
130
210
|
end
|
131
211
|
|
132
212
|
def find_refs(hash, type='Reference', parent='')
|
@@ -196,8 +276,7 @@ module Aws
|
|
196
276
|
|
197
277
|
# --------------------------------------------------------------------------------
|
198
278
|
def get_file_set(want, path, exts=[])
|
199
|
-
|
200
|
-
raise "Bad call to #{self.class.name}.getPathSet: want == nil" unless want
|
279
|
+
raise "Bad call to #{self.class.name}.get_file_set: want == nil" unless want
|
201
280
|
@logger.debug "Look for #{want.ai} in #{[path]} with #{exts} extensions"
|
202
281
|
if exts.nil?
|
203
282
|
exts = @config[:precedence]
|
@@ -225,7 +304,7 @@ module Aws
|
|
225
304
|
end
|
226
305
|
}
|
227
306
|
rescue RegexpError => e
|
228
|
-
raise
|
307
|
+
raise "The regular expression attempting to match resources in '#{path}' is incorrect! #{e.message}"
|
229
308
|
end
|
230
309
|
@logger.debug "getPathSet set=#{set.ai}"
|
231
310
|
res = {}
|
@@ -236,92 +315,78 @@ module Aws
|
|
236
315
|
h = set[e]
|
237
316
|
if h
|
238
317
|
h.each{ |n,f|
|
239
|
-
@logger.
|
318
|
+
@logger.info "Ignoring #{File.basename(res[n])}" if res[n]
|
240
319
|
res[n] = f
|
241
320
|
}
|
242
321
|
else
|
243
|
-
@logger.
|
322
|
+
@logger.debug "'#{e}' set is empty! (No #{path}/*.#{e} files found using precedence #{exts})"
|
244
323
|
end
|
245
324
|
}
|
246
|
-
|
325
|
+
res
|
247
326
|
end
|
248
327
|
|
249
|
-
def
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
328
|
+
def map_resource_reference(rsrc)
|
329
|
+
path = nil
|
330
|
+
sub = nil
|
331
|
+
ref = nil
|
332
|
+
rel = false
|
333
|
+
# noinspection RubyParenthesesAroundConditionInspection
|
334
|
+
if rsrc.match %r'^(\.\./.*?)::(.*)$'
|
335
|
+
# Relative path stack reference
|
336
|
+
path,sub,ref,rel = map_resource_reference(File.basename(rsrc))
|
337
|
+
elsif rsrc.match %r'^(\.\./[^:]*?)$'
|
338
|
+
# Relative path
|
339
|
+
path = File.dirname(rsrc)
|
340
|
+
sub = File.basename(path)
|
341
|
+
path = File.dirname(path)
|
342
|
+
ref = File.basename(rsrc)
|
343
|
+
rel = true
|
344
|
+
elsif rsrc.match %r'(^/.*?[^:]*?)$'
|
345
|
+
# Absolute path
|
346
|
+
path = File.dirname(rsrc)
|
347
|
+
sub = File.basename(path)
|
348
|
+
path = File.dirname(path)
|
349
|
+
ref = File.basename(rsrc)
|
350
|
+
elsif rsrc.match %r'(^/.*?)::(.*)$'
|
351
|
+
# Absolute path
|
352
|
+
path = File.dirname(rsrc)
|
353
|
+
ref = map_resource_reference(File.basename(rsrc))
|
354
|
+
elsif (match = rsrc.match %r'^(.*?)::(.*)$')
|
355
|
+
# Inherited stack reference
|
356
|
+
ref = match[2]
|
357
|
+
# noinspection RubyParenthesesAroundConditionInspection
|
358
|
+
if (subm = match[1].match(%r'^(.+?)/(.+)$'))
|
359
|
+
path = File.join(File.dirname(@opts[:directory]),subm[1])
|
360
|
+
sub = subm[2]
|
258
361
|
else
|
259
|
-
|
260
|
-
|
261
|
-
set = get_file_set(['.*'], dir.downcase, @config[:precedence])
|
262
|
-
else
|
263
|
-
@logger.error " !! error: Cannot load bricks from #{File.join(@opts[:directory], dir)}"
|
264
|
-
abort!
|
265
|
-
end
|
362
|
+
# sub = nil
|
363
|
+
path = File.join(File.dirname(@opts[:directory]),match[1])
|
266
364
|
end
|
365
|
+
else
|
366
|
+
# Otherwise it is what it seems ;)
|
367
|
+
ref = rsrc
|
368
|
+
end
|
369
|
+
[path,sub,ref,rel]
|
370
|
+
end
|
267
371
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
@logger.info "Brick not supported/ relevant: #{filename}"
|
280
|
-
next
|
281
|
-
end
|
282
|
-
|
283
|
-
begin
|
284
|
-
@logger.step " reading #{filename}"
|
285
|
-
content = File.read(filename)
|
286
|
-
next if content.size==0
|
287
|
-
|
288
|
-
if filename =~ /\.(rb|ruby)\z/i
|
289
|
-
eval "@dsl.#{content.gsub(%r'^\s+','')}"
|
290
|
-
unless @dsl.dict[dir.to_sym]
|
291
|
-
raise "Unable to expand #{filename} for #{dir}/#{base}"
|
292
|
-
end
|
293
|
-
item.merge! @dsl.dict[dir.to_sym]
|
294
|
-
elsif filename =~ /\.js(|on)\z/i
|
295
|
-
item.merge! JSON.parse(content)
|
296
|
-
elsif filename =~ /\.ya?ml\z/i
|
297
|
-
item.merge! YAML.load(content)
|
298
|
-
else
|
299
|
-
next
|
300
|
-
end
|
301
|
-
|
302
|
-
rescue
|
303
|
-
@logger.error " !! error: #{$!}"
|
304
|
-
abort!
|
305
|
-
end
|
306
|
-
else
|
307
|
-
@logger.error " !! error: #{dir}/#{base} not found!"
|
308
|
-
abort!
|
309
|
-
end
|
310
|
-
end
|
311
|
-
item.keys.each { |key|
|
312
|
-
if @items[dir].has_key?(key)
|
313
|
-
@logger.error " !! error: Duplicate item: #{dir}/#{key}"
|
314
|
-
abort!
|
315
|
-
end
|
316
|
-
}
|
317
|
-
@items[dir].merge! item
|
318
|
-
|
319
|
-
unless @items[dir].keys.count == spec[dir].count
|
320
|
-
@logger.error " !! error: Suspect that a #{dir} item was missed! \nRequested: #{spec[dir]}\n Found: #{@items[dir].keys}"
|
321
|
-
abort!
|
372
|
+
def vet_path(dir,base=nil,rel=false)
|
373
|
+
if rel
|
374
|
+
base = File.realpath(File.expand_path(File.join(@opts[:directory], base)))
|
375
|
+
else
|
376
|
+
base = @opts[:directory] unless base
|
377
|
+
end
|
378
|
+
path = nil
|
379
|
+
[dir, dir.downcase].each do |d|
|
380
|
+
path = File.join(base, dir)
|
381
|
+
if File.directory?(path)
|
382
|
+
break
|
322
383
|
end
|
323
384
|
end
|
324
|
-
|
385
|
+
unless File.directory?(path)
|
386
|
+
@logger.error " !! error: Cannot load bricks from #{path} (started with #{File.join(base, dir)}')"
|
387
|
+
abort!
|
388
|
+
end
|
389
|
+
path
|
325
390
|
end
|
326
391
|
|
327
392
|
end
|
@@ -12,6 +12,7 @@ module Aws
|
|
12
12
|
def run
|
13
13
|
|
14
14
|
@opts = Slop.parse(help: true) do
|
15
|
+
# command File.basename(__FILE__,'.rb')
|
15
16
|
on :d, :directory=, 'The directory to look in', as: String
|
16
17
|
on :o, :output=, 'The JSON file to output', as: String
|
17
18
|
on :s, :specification=, 'The specification to use when selecting components. A JSON or YAML file or JSON object', as: String
|
@@ -49,15 +50,12 @@ module Aws
|
|
49
50
|
'Outputs' => @items['Outputs'],
|
50
51
|
}
|
51
52
|
|
52
|
-
@logger.step'Validating compiled file...'
|
53
|
-
|
54
53
|
validate(compiled)
|
55
54
|
|
56
55
|
output_file = @opts[:output] || 'compiled.json'
|
57
|
-
save(compiled
|
56
|
+
save(output_file,compiled)
|
58
57
|
|
59
|
-
|
60
|
-
@logger.step'*** Compiled Successfully ***'
|
58
|
+
@logger.step '*** Compiled Successfully ***'
|
61
59
|
end
|
62
60
|
|
63
61
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PKinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|