cfhighlander 0.3.0.alpha.1531308925 → 0.3.0.alpha.1531438371
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 +4 -4
- data/bin/cfhighlander.rb +1 -3
- data/lib/cfhighlander.compiler.rb +1 -0
- data/lib/cfhighlander.dsl.base.rb +46 -2
- data/lib/cfhighlander.dsl.subcomponent.rb +21 -1
- data/lib/cfhighlander.dsl.template.rb +37 -24
- data/lib/util/zip.util.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99bdc92897ee6f2ce760495c539412309eb65cd134a08b51ffcb5abc0a6757aa
|
4
|
+
data.tar.gz: b19a2169d07759c991d71d90490d95753b9a230e00441f814769ccd3797eedc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5555333f992766a2a0ca527bc0737c088759227e4e44f104f164503b4d70b01c97a7a6fc7c545f7354c36b08570d03623ece3cb5674d02dc25638782451f23d8
|
7
|
+
data.tar.gz: 74bee959517244870bd3425128b18e6f1fb2eaa1d214f50ed37d47fb7d897e29d78779c8c2c4e501442d3601f31ebf535f72d1b9995e40bd0408c35c27b262b3
|
data/bin/cfhighlander.rb
CHANGED
@@ -276,6 +276,7 @@ module Cfhighlander
|
|
276
276
|
# executing package command can generate files. We DO NOT want this file in source directory,
|
277
277
|
# but rather in intermediate directory
|
278
278
|
tmp_source_dir = "#{@workdir}/out/lambdas/tmp/#{name}"
|
279
|
+
FileUtils.rmtree(File.dirname(tmp_source_dir)) if File.exist? tmp_source_dir
|
279
280
|
FileUtils.mkpath(File.dirname(tmp_source_dir))
|
280
281
|
FileUtils.copy_entry(lambda_source_dir, tmp_source_dir)
|
281
282
|
lambda_source_dir = tmp_source_dir
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Cfhighlander
|
3
2
|
|
4
3
|
module Dsl
|
@@ -6,7 +5,52 @@ module Cfhighlander
|
|
6
5
|
|
7
6
|
attr_accessor :config
|
8
7
|
|
9
|
-
|
8
|
+
|
9
|
+
def GetAtt(resource, property)
|
10
|
+
return FnGetAtt(resource, property)
|
11
|
+
end
|
12
|
+
|
13
|
+
def FnGetAtt(resource, property)
|
14
|
+
return {
|
15
|
+
'Fn::GetAtt' => [resource, property]
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def Ref(resource)
|
20
|
+
return {
|
21
|
+
'Ref' => resource
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def FnFindInMap(map, key, attr)
|
26
|
+
return { 'Fn::FindInMap' => [map, key, attr] }
|
27
|
+
end
|
28
|
+
|
29
|
+
def FindInMap(map, key, attr)
|
30
|
+
return FnFindInMap(map, key, attr)
|
31
|
+
end
|
32
|
+
|
33
|
+
def cfout(resource, output = nil)
|
34
|
+
if output.nil?
|
35
|
+
parts = resource.split('.')
|
36
|
+
if parts.size() != 2
|
37
|
+
raise "cfout('#{resource}'): If cfout given single argument cfout('component.OutputName') syntax must be used"
|
38
|
+
else
|
39
|
+
resource = parts[0]
|
40
|
+
output = parts[1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
return GetAtt(resource, "Outputs.#{output}")
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def cfmap(map, key, attr)
|
49
|
+
return FindInMap(map, key, attr)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def initialize (parent)
|
10
54
|
@config = parent.config unless parent.nil?
|
11
55
|
end
|
12
56
|
|
@@ -63,7 +63,7 @@ module Cfhighlander
|
|
63
63
|
@template = template_name
|
64
64
|
@template_version = template_version
|
65
65
|
@name = name
|
66
|
-
@cfn_name = @name.gsub('-','').gsub('_','').gsub(' ','')
|
66
|
+
@cfn_name = @name.gsub('-', '').gsub('_', '').gsub(' ', '')
|
67
67
|
@param_values = param_values
|
68
68
|
|
69
69
|
# distribution settings
|
@@ -131,6 +131,26 @@ module Cfhighlander
|
|
131
131
|
@param_values[name] = value
|
132
132
|
end
|
133
133
|
|
134
|
+
def config(key = '', value = '')
|
135
|
+
@component_loaded.config[key] = value
|
136
|
+
end
|
137
|
+
|
138
|
+
def ConfigParameter(config_key:, parameter:, defaultValue: '', type: 'String')
|
139
|
+
Parameters do
|
140
|
+
ComponentParam parameter, defaultValue, type: type
|
141
|
+
end
|
142
|
+
config config_key, Ref(parameter)
|
143
|
+
end
|
144
|
+
|
145
|
+
## for all the message received, try and forward them to load component dsl
|
146
|
+
def method_missing(method, *args, &block)
|
147
|
+
child_dsl = @component_loaded.highlander_dsl
|
148
|
+
if child_dsl.respond_to? method
|
149
|
+
# child_dsl.method
|
150
|
+
child_dsl.send method, *args, &block
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
134
154
|
# Parameters should be lazy loaded, that is late-binding should happen once
|
135
155
|
# all parameters and mappings are known
|
136
156
|
def resolve_parameter_values(available_outputs)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
extensions_folder = "#{File.dirname(__FILE__)}/../hl_ext"
|
4
4
|
|
5
|
-
Dir["#{extensions_folder}/*.rb"].each {
|
5
|
+
Dir["#{extensions_folder}/*.rb"].each {|f|
|
6
6
|
require f
|
7
7
|
}
|
8
8
|
|
@@ -56,8 +56,10 @@ module Cfhighlander
|
|
56
56
|
@dependson_components_templates = []
|
57
57
|
@dependson_components = []
|
58
58
|
@conditions = []
|
59
|
-
@config_overrides = {}
|
59
|
+
@config_overrides = {}
|
60
60
|
@extended_template = nil
|
61
|
+
# execution blocks for subcomponents
|
62
|
+
@subcomponents_exec = {}
|
61
63
|
end
|
62
64
|
|
63
65
|
# DSL statements
|
@@ -84,16 +86,20 @@ module Cfhighlander
|
|
84
86
|
|
85
87
|
def Parameters(&block)
|
86
88
|
@parameters.config = @config
|
87
|
-
@parameters.instance_eval(&block)
|
89
|
+
@parameters.instance_eval(&block) unless block.nil?
|
88
90
|
end
|
89
91
|
|
92
|
+
# def ComponentParam(argc*, argv)
|
93
|
+
# @parameters.ComponentParam(argc, argv)
|
94
|
+
# end
|
95
|
+
|
90
96
|
def Condition(name, expression)
|
91
97
|
@conditions << Condition.new(name, expression)
|
92
98
|
end
|
93
99
|
|
94
100
|
def DynamicMappings(providerName)
|
95
101
|
maps = mappings_provider_maps(providerName, self.config)
|
96
|
-
maps.each {
|
102
|
+
maps.each {|name, map| addMapping(name, map)} unless maps.nil?
|
97
103
|
end
|
98
104
|
|
99
105
|
def DependsOn(template)
|
@@ -133,7 +139,8 @@ module Cfhighlander
|
|
133
139
|
conditional,
|
134
140
|
enabled
|
135
141
|
)
|
136
|
-
component.instance_eval(&block) unless block.nil?
|
142
|
+
# component.instance_eval(&block) unless block.nil?
|
143
|
+
@subcomponents_exec[name] = block unless block.nil?
|
137
144
|
component.distribute_bucket = @distribution_bucket unless @distribution_bucket.nil?
|
138
145
|
component.distribute_prefix = @distribution_prefix unless @distribution_prefix.nil?
|
139
146
|
component.version = @version unless @version.nil?
|
@@ -188,11 +195,11 @@ module Cfhighlander
|
|
188
195
|
|
189
196
|
# Internal and interface functions
|
190
197
|
|
191
|
-
def loadComponents
|
198
|
+
def loadComponents
|
192
199
|
|
193
200
|
# empty config overrides to start with
|
194
|
-
@config_overrides = Hash[@subcomponents.collect {
|
195
|
-
@named_components = Hash[@subcomponents.collect {
|
201
|
+
@config_overrides = Hash[@subcomponents.collect {|c| [c.name, { 'nested_component' => true }]}]
|
202
|
+
@named_components = Hash[@subcomponents.collect {|c| [c.name, c]}]
|
196
203
|
|
197
204
|
# populate overrides with master config defined overrides
|
198
205
|
load_configfile_component_config
|
@@ -217,6 +224,7 @@ module Cfhighlander
|
|
217
224
|
@subcomponents.each do |component|
|
218
225
|
|
219
226
|
component.load @config_overrides[component.name]
|
227
|
+
|
220
228
|
# add all of it's stack parameters unless same template has been already processed
|
221
229
|
component
|
222
230
|
.component_loaded
|
@@ -241,8 +249,10 @@ module Cfhighlander
|
|
241
249
|
end
|
242
250
|
|
243
251
|
end
|
244
|
-
|
245
|
-
|
252
|
+
if @subcomponents_exec.key? component.name
|
253
|
+
component.instance_eval &@subcomponents_exec[component.name]
|
254
|
+
end
|
255
|
+
component.component_loaded.eval_cfndsl
|
246
256
|
end
|
247
257
|
|
248
258
|
# in 2nd pass, load parameters
|
@@ -291,14 +301,14 @@ module Cfhighlander
|
|
291
301
|
end
|
292
302
|
|
293
303
|
def apply_config_overrides
|
294
|
-
@config_overrides.each {
|
304
|
+
@config_overrides.each {|component_name, component_override|
|
295
305
|
@named_components[component_name].component_loaded.config.extend(component_override)
|
296
306
|
}
|
297
307
|
end
|
298
308
|
|
299
309
|
def load_configfile_component_config
|
300
310
|
if (@config.key? 'components')
|
301
|
-
@config['components'].each {
|
311
|
+
@config['components'].each {|component_name, component_config|
|
302
312
|
if component_config.key?('config')
|
303
313
|
if @config_overrides.key? component_name
|
304
314
|
@config_overrides[component_name].extend(component_config['config'])
|
@@ -313,28 +323,28 @@ module Cfhighlander
|
|
313
323
|
def apply_config_exports
|
314
324
|
# first export from master to all children
|
315
325
|
if ((@config.key? 'config_export') and (@config['config_export']['global']))
|
316
|
-
@config['config_export']['global'].each {
|
326
|
+
@config['config_export']['global'].each {|global_export_key|
|
317
327
|
if @config.key? global_export_key
|
318
|
-
@config_overrides.each {
|
328
|
+
@config_overrides.each {|cname, co|
|
319
329
|
co[global_export_key] = @config[global_export_key]
|
320
330
|
}
|
321
331
|
end
|
322
332
|
}
|
323
333
|
end
|
324
334
|
|
325
|
-
@subcomponents.each {
|
335
|
+
@subcomponents.each {|component|
|
326
336
|
cl = component.component_loaded
|
327
337
|
if ((not cl.config.nil?) and (cl.config.key? 'config_export'))
|
328
338
|
|
329
339
|
# global config
|
330
340
|
if cl.config['config_export'].key? 'global'
|
331
|
-
cl.config['config_export']['global'].each {
|
341
|
+
cl.config['config_export']['global'].each {|global_export_key|
|
332
342
|
|
333
343
|
# global config is exported to parent and every component
|
334
344
|
if cl.config.key? global_export_key
|
335
345
|
|
336
346
|
# cname is for component name, co for component override
|
337
|
-
@config_overrides.each {
|
347
|
+
@config_overrides.each {|cname, co|
|
338
348
|
|
339
349
|
# if templates are different e.g don't export from vpc to vpc
|
340
350
|
config_receiver_component = @named_components[cname]
|
@@ -360,7 +370,7 @@ module Cfhighlander
|
|
360
370
|
end
|
361
371
|
|
362
372
|
if cl.config['config_export'].key? 'component'
|
363
|
-
cl.config['config_export']['component'].each {
|
373
|
+
cl.config['config_export']['component'].each {|component_name, export_keys|
|
364
374
|
# check if there is configuration of export from this component
|
365
375
|
# and if there is export configuration for given component name
|
366
376
|
|
@@ -369,7 +379,7 @@ module Cfhighlander
|
|
369
379
|
if @config_overrides.key? component.export_config[component_name]
|
370
380
|
# override the config
|
371
381
|
real_component_name = component.export_config[component_name]
|
372
|
-
export_keys.each {
|
382
|
+
export_keys.each {|export_component_key|
|
373
383
|
puts("Exporting config for key=#{export_component_key} from #{component.name} to #{real_component_name}")
|
374
384
|
if not @config_overrides[real_component_name].key? export_component_key
|
375
385
|
@config_overrides[real_component_name][export_component_key] = {}
|
@@ -380,7 +390,7 @@ module Cfhighlander
|
|
380
390
|
STDERR.puts("Trying to export configuration for non-existant component #{component.export_config[component_name]}")
|
381
391
|
end
|
382
392
|
elsif @config_overrides.key? component_name
|
383
|
-
export_keys.each {
|
393
|
+
export_keys.each {|export_component_key|
|
384
394
|
puts("Exporting config for key=#{export_component_key} from #{component.name} to #{component_name}")
|
385
395
|
if not @config_overrides[component_name].key? export_component_key
|
386
396
|
@config_overrides[component_name][export_component_key] = {}
|
@@ -400,7 +410,7 @@ module Cfhighlander
|
|
400
410
|
end
|
401
411
|
|
402
412
|
def load_explicit_component_config
|
403
|
-
@component_configs.each {
|
413
|
+
@component_configs.each {|component_name, component_config|
|
404
414
|
@config_overrides[component_name].extend(component_config)
|
405
415
|
}
|
406
416
|
|
@@ -424,7 +434,7 @@ module Cfhighlander
|
|
424
434
|
if not (@distribution_bucket.nil? or @distribution_prefix.nil?)
|
425
435
|
@distribute_url = "https://#{@distribution_bucket}.s3.amazonaws.com/#{@distribution_prefix}"
|
426
436
|
@distribute_url = "#{@distribute_url}/#{@version}" unless @version.nil?
|
427
|
-
@subcomponents.each {
|
437
|
+
@subcomponents.each {|component|
|
428
438
|
component.distribute_bucket = @distribution_bucket unless @distribution_bucket.nil?
|
429
439
|
component.distribute_prefix = @distribution_prefix unless @distribution_prefix.nil?
|
430
440
|
component.version = @version unless @version.nil?
|
@@ -472,12 +482,15 @@ def CfhighlanderTemplate(&block)
|
|
472
482
|
unless @distribution_prefix.nil?
|
473
483
|
instance.DistributionPrefix(@distribution_prefix)
|
474
484
|
end
|
485
|
+
unless @distribution_format.nil?
|
486
|
+
instance.Forma
|
487
|
+
end
|
475
488
|
|
476
489
|
# process convention over configuration componentname.config.yaml files
|
477
490
|
@potential_subcomponent_overrides.each do |name, config|
|
478
491
|
|
479
492
|
# if there is component with given file name
|
480
|
-
if (not instance.subcomponents.find{|s|s.name == name}.nil?)
|
493
|
+
if (not instance.subcomponents.find {|s| s.name == name}.nil?)
|
481
494
|
instance.config['components'] = {} unless instance.config.key? 'components'
|
482
495
|
instance.config['components'][name] = {} unless instance.config['components'].key? name
|
483
496
|
instance.config['components'][name]['config'] = {} unless instance.config['components'][name].key? 'config'
|
@@ -486,7 +499,7 @@ def CfhighlanderTemplate(&block)
|
|
486
499
|
if config.key? 'components'
|
487
500
|
if config['components'].key? name
|
488
501
|
if config['components'][name].key? 'config'
|
489
|
-
|
502
|
+
config = config['components'][name]['config']
|
490
503
|
end
|
491
504
|
end
|
492
505
|
end
|
data/lib/util/zip.util.rb
CHANGED
@@ -17,7 +17,7 @@ module Cfhighlander
|
|
17
17
|
# Zip the input directory.
|
18
18
|
def write
|
19
19
|
entries = Dir.entries(@input_dir) - %w(. ..)
|
20
|
-
|
20
|
+
puts "DEBUG: Compressing #{@input_dir} to #{@output_file}"
|
21
21
|
::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile|
|
22
22
|
write_entries entries, '', zipfile
|
23
23
|
end
|
@@ -30,7 +30,6 @@ module Cfhighlander
|
|
30
30
|
entries.each do |e|
|
31
31
|
zipfile_path = path == '' ? e : File.join(path, e)
|
32
32
|
disk_file_path = File.join(@input_dir, zipfile_path)
|
33
|
-
puts "TRACE: Deflating #{disk_file_path}"
|
34
33
|
|
35
34
|
if File.directory? disk_file_path
|
36
35
|
recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfhighlander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.alpha.
|
4
|
+
version: 0.3.0.alpha.1531438371
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Tosic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-07-
|
12
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|