cfhighlander 0.3.0.alpha.1531198720 → 0.3.0.alpha.1531270316
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfhighlander.dsl.subcomponent.rb +1 -1
- data/lib/cfhighlander.dsl.template.rb +16 -6
- data/lib/cfhighlander.factory.rb +4 -1
- data/lib/cfhighlander.model.component.rb +67 -14
- 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: e24583ffb52dd7b67178ec79684808d14fd0219a9ca6a03aa3a42fc249971fe7
|
4
|
+
data.tar.gz: 7f42b19cb4f05b087bdcf31593a53c04db7008d5c2670273d4b00134aa2007ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b237aebd3bbd2084945f494d41ef9599f73e5d91f18263fc8434fb061ebc65c61ebde430c9de0fa76833fa7324fcbc12efa308ebcbc8ae8c9427a4a4480b356b
|
7
|
+
data.tar.gz: 64712d1386bf517399b47aadb51f53fc11177737386201e7c2e25ed26888039ab59dc056c2c48fe2e41b94d9d5aff72a19c11cbc104e7632dc62ceefa07049f8
|
@@ -152,7 +152,7 @@ module Cfhighlander
|
|
152
152
|
class SubcomponentParamValueResolver
|
153
153
|
def self.resolveValue(component, sub_component, param, available_outputs)
|
154
154
|
|
155
|
-
|
155
|
+
puts("INFO Resolving parameter #{component.name} -> #{sub_component.name}.#{param.name}: ")
|
156
156
|
|
157
157
|
# rule 0: this rule is here for legacy reasons and OutputParam. It should be deprecated
|
158
158
|
# once all hl-components- repos remove any references to OutputParam
|
@@ -39,7 +39,8 @@ module Cfhighlander
|
|
39
39
|
|
40
40
|
attr_reader :conditions,
|
41
41
|
:subcomponents,
|
42
|
-
:config_overrides
|
42
|
+
:config_overrides,
|
43
|
+
:extended_template
|
43
44
|
|
44
45
|
def initialize
|
45
46
|
@mappings = []
|
@@ -55,7 +56,8 @@ module Cfhighlander
|
|
55
56
|
@dependson_components_templates = []
|
56
57
|
@dependson_components = []
|
57
58
|
@conditions = []
|
58
|
-
@config_overrides = {}
|
59
|
+
@config_overrides = {},
|
60
|
+
@extended_template = nil
|
59
61
|
end
|
60
62
|
|
61
63
|
# DSL statements
|
@@ -98,6 +100,9 @@ module Cfhighlander
|
|
98
100
|
@dependson_components_templates << template
|
99
101
|
end
|
100
102
|
|
103
|
+
def Extends(template)
|
104
|
+
@extended_template = template
|
105
|
+
end
|
101
106
|
|
102
107
|
def Component(template_arg = nil, template: nil,
|
103
108
|
name: template,
|
@@ -435,11 +440,16 @@ module Cfhighlander
|
|
435
440
|
end
|
436
441
|
|
437
442
|
def CfhighlanderTemplate(&block)
|
438
|
-
instance = Cfhighlander::Dsl::HighlanderTemplate.new
|
439
|
-
|
440
|
-
puts "Processing cfhighlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
|
441
|
-
"\n\tConfig:#{@config}"
|
442
443
|
|
444
|
+
if @parent_dsl.nil?
|
445
|
+
instance = Cfhighlander::Dsl::HighlanderTemplate.new
|
446
|
+
puts "Processing higlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
|
447
|
+
"\n\tConfig:#{@config}"
|
448
|
+
else
|
449
|
+
instance = @parent_dsl
|
450
|
+
puts "Processing higlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
|
451
|
+
"\n\tConfig:#{@config}\n\tParent: #{@parent_template}"
|
452
|
+
end
|
443
453
|
|
444
454
|
instance.config = @config
|
445
455
|
|
data/lib/cfhighlander.factory.rb
CHANGED
@@ -34,7 +34,10 @@ module Cfhighlander
|
|
34
34
|
|
35
35
|
|
36
36
|
def buildComponentFromLocation(template_meta, component_name)
|
37
|
-
component = Model::Component.new(template_meta,
|
37
|
+
component = Model::Component.new(template_meta,
|
38
|
+
component_name,
|
39
|
+
self)
|
40
|
+
component.factory = self
|
38
41
|
component.load_config
|
39
42
|
return component
|
40
43
|
end
|
@@ -20,13 +20,21 @@ module Cfhighlander
|
|
20
20
|
:distribution_prefix,
|
21
21
|
:component_files,
|
22
22
|
:cfndsl_ext_files,
|
23
|
-
:lambda_src_files
|
23
|
+
:lambda_src_files,
|
24
|
+
:parent_template,
|
25
|
+
:template_finder,
|
26
|
+
:factory,
|
27
|
+
:extended_component,
|
28
|
+
:is_parent_component
|
24
29
|
|
25
30
|
attr_reader :cfn_model,
|
26
31
|
:outputs,
|
32
|
+
:factory,
|
33
|
+
:extended_component,
|
27
34
|
:potential_subcomponent_overrides
|
28
35
|
|
29
|
-
|
36
|
+
|
37
|
+
def initialize(template_meta, component_name, factory)
|
30
38
|
@template = template_meta
|
31
39
|
@name = component_name
|
32
40
|
@component_dir = template_meta.template_location
|
@@ -37,7 +45,11 @@ module Cfhighlander
|
|
37
45
|
@component_files = []
|
38
46
|
@cfndsl_ext_files = []
|
39
47
|
@lambda_src_files = []
|
48
|
+
@factory = factory
|
49
|
+
@extended_component = nil
|
50
|
+
@parent_dsl = nil
|
40
51
|
@potential_subcomponent_overrides = {}
|
52
|
+
@is_parent_component = false
|
41
53
|
end
|
42
54
|
|
43
55
|
def distribution_bucket=(value)
|
@@ -65,7 +77,7 @@ module Cfhighlander
|
|
65
77
|
@component_files << config_file
|
66
78
|
end
|
67
79
|
fname = File.basename(config_file)
|
68
|
-
potential_component_name = fname.gsub('.config.yaml','')
|
80
|
+
potential_component_name = fname.gsub('.config.yaml', '')
|
69
81
|
@potential_subcomponent_overrides[potential_component_name] = partial_config
|
70
82
|
end
|
71
83
|
end
|
@@ -99,7 +111,7 @@ module Cfhighlander
|
|
99
111
|
candidate_dynamic_mappings_path = "#{@component_dir}/#{@template.template_name}.mappings.rb"
|
100
112
|
|
101
113
|
@cfndsl_ext_files += Dir["#{@component_dir}/ext/cfndsl/*.rb"]
|
102
|
-
@lambda_src_files += Dir["#{@component_dir}/lambdas/**/*"].find_all {|p| not File.directory? p}
|
114
|
+
@lambda_src_files += Dir["#{@component_dir}/lambdas/**/*"].find_all { |p| not File.directory? p }
|
103
115
|
@component_files += @cfndsl_ext_files
|
104
116
|
@component_files += @lambda_src_files
|
105
117
|
|
@@ -125,16 +137,11 @@ module Cfhighlander
|
|
125
137
|
@component_files << candidate_dynamic_mappings_path
|
126
138
|
end
|
127
139
|
|
128
|
-
# 1st pass - parse the file
|
129
140
|
@component_files << @highlander_dsl_path
|
130
141
|
|
131
|
-
cfhl_script = ''
|
132
|
-
@config.each do |key, val|
|
133
|
-
cfhl_script += ("\n#{key} = #{val.inspect}\n")
|
134
|
-
end
|
135
|
-
cfhl_script += File.read(@highlander_dsl_path)
|
136
142
|
|
137
|
-
|
143
|
+
# evaluate template file and load parent if defined
|
144
|
+
evaluateHiglanderTemplate
|
138
145
|
|
139
146
|
# set version if not defined
|
140
147
|
@highlander_dsl.ComponentVersion(@version) unless @version.nil?
|
@@ -149,12 +156,39 @@ module Cfhighlander
|
|
149
156
|
end
|
150
157
|
|
151
158
|
@highlander_dsl.Description(description)
|
152
|
-
end
|
159
|
+
end unless @is_parent_component
|
153
160
|
|
154
161
|
# set (override) distribution options
|
155
162
|
@highlander_dsl.DistributionBucket(@distribution_bucket) unless @distribution_bucket.nil?
|
156
163
|
@highlander_dsl.DistributionPrefix(@distribution_prefix) unless @distribution_prefix.nil?
|
157
164
|
|
165
|
+
|
166
|
+
loadDepandantExt()
|
167
|
+
end
|
168
|
+
|
169
|
+
def inheritParentTemplate
|
170
|
+
if not @parent_template.nil?
|
171
|
+
extended_component = @factory.loadComponentFromTemplate(@parent_template)
|
172
|
+
extended_component.is_parent_component = true
|
173
|
+
extended_component.load()
|
174
|
+
|
175
|
+
@config = extended_component.config.extend(@config)
|
176
|
+
@mappings = extended_component.mappings.extend(@mappings)
|
177
|
+
@cfndsl_ext_files += extended_component.cfndsl_ext_files
|
178
|
+
@lambda_src_files += extended_component.lambda_src_files
|
179
|
+
@extended_component = extended_component
|
180
|
+
|
181
|
+
# extend cfndsl, first comes parent, than child
|
182
|
+
# this allows for child component to shadow parent component
|
183
|
+
# defined resources
|
184
|
+
@cfndsl_content = extended_component.cfndsl_content + @cfndsl_content
|
185
|
+
|
186
|
+
@parent_dsl = extended_component.highlander_dsl
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def loadCfndslContent
|
158
192
|
if File.exist? @cfndsl_path
|
159
193
|
@component_files << @cfndsl_path
|
160
194
|
@cfndsl_content = File.read(@cfndsl_path)
|
@@ -169,8 +203,27 @@ module Cfhighlander
|
|
169
203
|
else
|
170
204
|
@cfndsl_content = ''
|
171
205
|
end
|
206
|
+
end
|
172
207
|
|
173
|
-
|
208
|
+
def evaluateHiglanderTemplate
|
209
|
+
loadCfndslContent
|
210
|
+
|
211
|
+
cfhl_script = ''
|
212
|
+
@config.each do |key, val|
|
213
|
+
cfhl_script += ("\n#{key} = #{val.inspect}\n")
|
214
|
+
end
|
215
|
+
cfhl_script += File.read(@highlander_dsl_path)
|
216
|
+
|
217
|
+
cfhl_dsl = eval(cfhl_script, binding)
|
218
|
+
if not cfhl_dsl.extended_template.nil?
|
219
|
+
@parent_template = cfhl_dsl.extended_template
|
220
|
+
inheritParentTemplate
|
221
|
+
puts "INFO: #{@template} extends #{@parent_template}, loading parent definition..."
|
222
|
+
# 2nd pass, template instance is already created from parent
|
223
|
+
@highlander_dsl = eval(cfhl_script, binding)
|
224
|
+
else
|
225
|
+
@highlander_dsl = cfhl_dsl
|
226
|
+
end
|
174
227
|
end
|
175
228
|
|
176
229
|
# evaluates cfndsl with current config
|
@@ -183,7 +236,7 @@ module Cfhighlander
|
|
183
236
|
@outputs = (
|
184
237
|
if @cfn_model.key? 'Outputs'
|
185
238
|
then
|
186
|
-
@cfn_model['Outputs'].map {|k, v| ComponentOutput.new self, k, v}
|
239
|
+
@cfn_model['Outputs'].map { |k, v| ComponentOutput.new self, k, v }
|
187
240
|
else
|
188
241
|
[]
|
189
242
|
end
|
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.1531270316
|
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-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|