cfhighlander 0.3.0.alpha.1530774510 → 0.3.0.alpha.1530842061

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aac59fddb269e962ce6360bcb3bfe4b7a8637141f102a3db0af6384dd70cf65
4
- data.tar.gz: 864f5122928958e8a92778a1c6cd6f1b766a9496e22b9931e6597f2e1206c979
3
+ metadata.gz: 0ff890e7dda9aff64ccbe2d3a5648f50a4ecc6469bf5cf8328fe4a348b6e1abc
4
+ data.tar.gz: d46584a0608d53c285d05331c7652d0b9869f47b4f21f23e42748465c6d4ff33
5
5
  SHA512:
6
- metadata.gz: 526e07eb3845b6841046fb0cd14c0fe6a499ea00f23ea51cfba87488de90f5534ad8ef5bb652be5de2b01193bb9a19f323dc6a48ba0817409afd2d0aa86b918f
7
- data.tar.gz: 90be475a470fdb6c1a31041a1fc0b0b11bfedb6ce83de65cd6161ca3b14753cf89ea4933d42809036dd38d74218a797d55e919c7eafb607c2837837ca8c55daa
6
+ metadata.gz: 125b66f793cddcc88e1d61c519a4e638d1396dfe5d531142632c1a875d573634f35aa132d13b3eb0691caf9fab272fe78ea7cc7402b87c61dda7e178db8c98f6
7
+ data.tar.gz: 6a5d8d1ef0c89b5579bc88887b43100ce4e0a349bee0382391f4236a16b671532f7e75ba36215f59e274fae39ed96691b200f31858c80a3635e2cb632a25a69e
data/README.md CHANGED
@@ -166,6 +166,21 @@ components:
166
166
 
167
167
  ```
168
168
  This configuration level overrides component's own config file.
169
+ Alternatively, to keep things less nested in configuration hierarchy, creating config file `vpc.config.yaml`
170
+ for component named `vpc` works just as well:
171
+
172
+ ```yaml
173
+
174
+ # contents of vpc.config.yaml in outer component, defining vpc component
175
+
176
+ # line below prevents component configuration file being merged with outer component configuration
177
+ subcomponent_config_file:
178
+
179
+ # there is no need for components/vpc/config structure, it is implied by file name
180
+ maximum_availibility_zones: 3
181
+
182
+
183
+ ```
169
184
 
170
185
 
171
186
  - Outer component explicit configuration. You can pass `config` named parameter to `Component` statement, such as
@@ -29,7 +29,8 @@ module Cfhighlander
29
29
  :cfn_output_location,
30
30
  :cfn_template_paths,
31
31
  :silent_mode,
32
- :lambda_src_paths
32
+ :lambda_src_paths,
33
+ :process_lambdas
33
34
 
34
35
  def initialize(component)
35
36
 
@@ -45,6 +46,7 @@ module Cfhighlander
45
46
  @lambda_src_paths = []
46
47
  @config_yaml_path = nil
47
48
  @cfn_model = nil
49
+ @process_lambdas = true
48
50
 
49
51
  if @@global_extensions_paths.empty?
50
52
  global_extensions_folder = "#{File.dirname(__FILE__)}/../cfndsl_ext"
@@ -58,6 +60,11 @@ module Cfhighlander
58
60
  end
59
61
  end
60
62
 
63
+ def process_lambdas=(value)
64
+ @process_lambdas = value
65
+ @sub_components.each { |scc| scc.process_lambdas=value }
66
+ end
67
+
61
68
  def silent_mode=(value)
62
69
  @silent_mode = value
63
70
  @sub_components.each { |scc| scc.silent_mode=value }
@@ -177,14 +184,13 @@ module Cfhighlander
177
184
  end
178
185
 
179
186
  def processLambdas()
180
-
181
187
  @component.highlander_dsl.lambda_functions_keys.each do |lfk|
182
188
  resolver = LambdaResolver.new(@component,
183
189
  lfk,
184
190
  @workdir,
185
191
  (not @silent_mode)
186
192
  )
187
- @lambda_src_paths += resolver.generateSourceArchives
193
+ @lambda_src_paths += resolver.generateSourceArchives if @process_lambdas
188
194
  resolver.mergeComponentConfig
189
195
  end
190
196
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  extensions_folder = "#{File.dirname(__FILE__)}/../hl_ext"
4
4
 
5
- Dir["#{extensions_folder}/*.rb"].each {|f|
5
+ Dir["#{extensions_folder}/*.rb"].each { |f|
6
6
  require f
7
7
  }
8
8
 
@@ -37,7 +37,9 @@ module Cfhighlander
37
37
  :description,
38
38
  :dependson_components
39
39
 
40
- attr_reader :conditions, :subcomponents
40
+ attr_reader :conditions,
41
+ :subcomponents,
42
+ :config_overrides
41
43
 
42
44
  def initialize
43
45
  @mappings = []
@@ -53,6 +55,7 @@ module Cfhighlander
53
55
  @dependson_components_templates = []
54
56
  @dependson_components = []
55
57
  @conditions = []
58
+ @config_overrides = {}
56
59
  end
57
60
 
58
61
  # DSL statements
@@ -88,7 +91,7 @@ module Cfhighlander
88
91
 
89
92
  def DynamicMappings(providerName)
90
93
  maps = mappings_provider_maps(providerName, self.config)
91
- maps.each {|name, map| addMapping(name, map)} unless maps.nil?
94
+ maps.each { |name, map| addMapping(name, map) } unless maps.nil?
92
95
  end
93
96
 
94
97
  def DependsOn(template)
@@ -183,8 +186,8 @@ module Cfhighlander
183
186
  def loadComponents()
184
187
 
185
188
  # empty config overrides to start with
186
- @config_overrides = Hash[@subcomponents.collect {|c| [c.name, { 'nested_component' => true }]}]
187
- @named_components = Hash[@subcomponents.collect {|c| [c.name, c]}]
189
+ @config_overrides = Hash[@subcomponents.collect { |c| [c.name, { 'nested_component' => true }] }]
190
+ @named_components = Hash[@subcomponents.collect { |c| [c.name, c] }]
188
191
 
189
192
  # populate overrides with master config defined overrides
190
193
  load_configfile_component_config
@@ -283,14 +286,14 @@ module Cfhighlander
283
286
  end
284
287
 
285
288
  def apply_config_overrides
286
- @config_overrides.each {|component_name, component_override|
289
+ @config_overrides.each { |component_name, component_override|
287
290
  @named_components[component_name].component_loaded.config.extend(component_override)
288
291
  }
289
292
  end
290
293
 
291
294
  def load_configfile_component_config
292
295
  if (@config.key? 'components')
293
- @config['components'].each {|component_name, component_config|
296
+ @config['components'].each { |component_name, component_config|
294
297
  if component_config.key?('config')
295
298
  if @config_overrides.key? component_name
296
299
  @config_overrides[component_name].extend(component_config['config'])
@@ -305,28 +308,28 @@ module Cfhighlander
305
308
  def apply_config_exports
306
309
  # first export from master to all children
307
310
  if ((@config.key? 'config_export') and (@config['config_export']['global']))
308
- @config['config_export']['global'].each {|global_export_key|
311
+ @config['config_export']['global'].each { |global_export_key|
309
312
  if @config.key? global_export_key
310
- @config_overrides.each {|cname, co|
313
+ @config_overrides.each { |cname, co|
311
314
  co[global_export_key] = @config[global_export_key]
312
315
  }
313
316
  end
314
317
  }
315
318
  end
316
319
 
317
- @subcomponents.each {|component|
320
+ @subcomponents.each { |component|
318
321
  cl = component.component_loaded
319
322
  if ((not cl.config.nil?) and (cl.config.key? 'config_export'))
320
323
 
321
324
  # global config
322
325
  if cl.config['config_export'].key? 'global'
323
- cl.config['config_export']['global'].each {|global_export_key|
326
+ cl.config['config_export']['global'].each { |global_export_key|
324
327
 
325
328
  # global config is exported to parent and every component
326
329
  if cl.config.key? global_export_key
327
330
 
328
331
  # cname is for component name, co for component override
329
- @config_overrides.each {|cname, co|
332
+ @config_overrides.each { |cname, co|
330
333
 
331
334
  # if templates are different e.g don't export from vpc to vpc
332
335
  config_receiver_component = @named_components[cname]
@@ -352,7 +355,7 @@ module Cfhighlander
352
355
  end
353
356
 
354
357
  if cl.config['config_export'].key? 'component'
355
- cl.config['config_export']['component'].each {|component_name, export_keys|
358
+ cl.config['config_export']['component'].each { |component_name, export_keys|
356
359
  # check if there is configuration of export from this component
357
360
  # and if there is export configuration for given component name
358
361
 
@@ -361,7 +364,7 @@ module Cfhighlander
361
364
  if @config_overrides.key? component.export_config[component_name]
362
365
  # override the config
363
366
  real_component_name = component.export_config[component_name]
364
- export_keys.each {|export_component_key|
367
+ export_keys.each { |export_component_key|
365
368
  puts("Exporting config for key=#{export_component_key} from #{component.name} to #{real_component_name}")
366
369
  if not @config_overrides[real_component_name].key? export_component_key
367
370
  @config_overrides[real_component_name][export_component_key] = {}
@@ -372,7 +375,7 @@ module Cfhighlander
372
375
  STDERR.puts("Trying to export configuration for non-existant component #{component.export_config[component_name]}")
373
376
  end
374
377
  elsif @config_overrides.key? component_name
375
- export_keys.each {|export_component_key|
378
+ export_keys.each { |export_component_key|
376
379
  puts("Exporting config for key=#{export_component_key} from #{component.name} to #{component_name}")
377
380
  if not @config_overrides[component_name].key? export_component_key
378
381
  @config_overrides[component_name][export_component_key] = {}
@@ -392,9 +395,10 @@ module Cfhighlander
392
395
  end
393
396
 
394
397
  def load_explicit_component_config
395
- @component_configs.each {|component_name, component_config|
398
+ @component_configs.each { |component_name, component_config|
396
399
  @config_overrides[component_name].extend(component_config)
397
400
  }
401
+
398
402
  end
399
403
 
400
404
  def distribute_bucket=(value)
@@ -415,7 +419,7 @@ module Cfhighlander
415
419
  if not (@distribution_bucket.nil? or @distribution_prefix.nil?)
416
420
  @distribute_url = "https://#{@distribution_bucket}.s3.amazonaws.com/#{@distribution_prefix}"
417
421
  @distribute_url = "#{@distribute_url}/#{@version}" unless @version.nil?
418
- @subcomponents.each {|component|
422
+ @subcomponents.each { |component|
419
423
  component.distribute_bucket = @distribution_bucket unless @distribution_bucket.nil?
420
424
  component.distribute_prefix = @distribution_prefix unless @distribution_prefix.nil?
421
425
  component.version = @version unless @version.nil?
@@ -458,6 +462,16 @@ def CfhighlanderTemplate(&block)
458
462
  instance.name = @template.template_name
459
463
  instance.instance_eval(&block)
460
464
 
465
+ # process convention over configuration componentname.config.yaml files
466
+ @potential_subcomponent_overrides.each do |name, config|
467
+ if (not instance.subcomponents.find{|s|s.name == name}.nil?)
468
+ instance.config['components'] = {} unless instance.config.key? 'components'
469
+ instance.config['components'][name] = {} unless instance.config['components'].key? name
470
+ instance.config['components'][name]['config'] = {} unless instance.config['components'][name].key? 'config'
471
+ instance.config['components'][name]['config'].extend config
472
+ end
473
+ end
474
+
461
475
  # load sub-components
462
476
  instance.loadComponents
463
477
 
@@ -22,7 +22,9 @@ module Cfhighlander
22
22
  :cfndsl_ext_files,
23
23
  :lambda_src_files
24
24
 
25
- attr_reader :cfn_model, :outputs
25
+ attr_reader :cfn_model,
26
+ :outputs,
27
+ :potential_subcomponent_overrides
26
28
 
27
29
  def initialize(template_meta, component_name)
28
30
  @template = template_meta
@@ -35,6 +37,7 @@ module Cfhighlander
35
37
  @component_files = []
36
38
  @cfndsl_ext_files = []
37
39
  @lambda_src_files = []
40
+ @potential_subcomponent_overrides = {}
38
41
  end
39
42
 
40
43
  # load component configuration files
@@ -43,10 +46,13 @@ module Cfhighlander
43
46
  Dir["#{@component_dir}/*.config.yaml"].each do |config_file|
44
47
  puts "INFO Loading config for #{@name}: read file:#{config_file} "
45
48
  partial_config = YAML.load(File.read(config_file))
46
- unless partial_config.nil?
49
+ unless (partial_config.nil? or partial_config.key? 'subcomponent_config_file')
47
50
  @config.extend(partial_config)
48
51
  @component_files << config_file
49
52
  end
53
+ fname = File.basename(config_file)
54
+ potential_component_name = fname.gsub('.config.yaml','')
55
+ @potential_subcomponent_overrides[potential_component_name] = partial_config
50
56
  end
51
57
  end
52
58
 
@@ -156,6 +162,9 @@ module Cfhighlander
156
162
  # evaluates cfndsl with current config
157
163
  def eval_cfndsl
158
164
  compiler = Cfhighlander::Compiler::ComponentCompiler.new self
165
+ # there is no need for processing lambda source code during cloudformation evaluation,
166
+ # this version never gets published
167
+ compiler.process_lambdas = false
159
168
  @cfn_model = compiler.evaluateCloudFormation().as_json
160
169
  @outputs = (
161
170
  if @cfn_model.key? 'Outputs'
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.1530774510
4
+ version: 0.3.0.alpha.1530842061
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-05 00:00:00.000000000 Z
12
+ date: 2018-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline