bora 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb9cb634611af62cf8cbcdf7a2e14dfce79c0ee
4
- data.tar.gz: b0be2ce0d4e56b6c39bca1eaca8e2368e20632f3
3
+ metadata.gz: ea4493a9644738e50bf62a8083150dfc6f1aa76e
4
+ data.tar.gz: c32798fe76ef04770c196b5700e406b1c6f6e1e0
5
5
  SHA512:
6
- metadata.gz: 371de3c1092a9b94aede3507bcd103e41b5b0ac9b34b15af07a9fa2017adb407bcdaf65f98e66684259702352b6a138218bcb64c814b8b1cdb665f9a10b850eb
7
- data.tar.gz: b4521c15f3dc649788233b09049926f4a3b3565bb0797886dbf1dbafba4e319441e713ab588f61dc074eb186f1883a26cada8a60edf747f64f90418dd754a08b
6
+ metadata.gz: 51e688533cfc524b0178efb0943e13caae0632fe4f0e38afd5006d0c8cee17e922b1ff70d5cb195a83d1a3fd17b49027decf3d116acea27ebd3e163fe1246996
7
+ data.tar.gz: 06f9d9b9ae1e690b02e24542107fad4c679865220cab46f394be233c56b2f02546031235957303d2bce7ba50540b8b87210a6f2937af99e6d8c0bafc823e8503
@@ -0,0 +1,22 @@
1
+ require 'bora/stack'
2
+
3
+ module Bora
4
+ class CfnParamResolver
5
+ def initialize(param)
6
+ @param = param
7
+ end
8
+
9
+ def resolve
10
+ stack, section, name = @param.split("/")
11
+ if !stack || !section || !name || section != 'outputs'
12
+ raise "Invalid parameter substitution: #{@param}"
13
+ end
14
+
15
+ outputs = Stack.new(stack).outputs
16
+ matching_output = outputs.find { |output| output.key == name }
17
+ raise "Output #{name} not found in stack #{stack}" if !matching_output
18
+ matching_output.value
19
+ end
20
+
21
+ end
22
+ end
@@ -4,6 +4,14 @@ module Bora
4
4
  @output = output
5
5
  end
6
6
 
7
+ def key
8
+ @output.output_key
9
+ end
10
+
11
+ def value
12
+ @output.output_value
13
+ end
14
+
7
15
  def to_s
8
16
  desc = @output.description ? " (#{@output.description})" : ""
9
17
  "#{@output.output_key} - #{@output.output_value} #{desc}"
@@ -4,6 +4,7 @@ require 'colorize'
4
4
  require 'rake/tasklib'
5
5
  require 'cfndsl'
6
6
  require 'bora/tasks'
7
+ require 'bora/cfn_param_resolver'
7
8
 
8
9
  module Bora
9
10
  class RakeTasks < Rake::TaskLib
@@ -33,8 +34,7 @@ module Bora
33
34
  Bora::Tasks.new(stack_name) do |t|
34
35
  if File.extname(template_file) == ".rb"
35
36
  task :generate do |_, args|
36
- params = stack_config['params']
37
- params.merge!(extract_params_from_args(args.extras))
37
+ params = extract_params(stack_config, args)
38
38
  stack_options[:template_body] = run_cfndsl(template_file, params)
39
39
  end
40
40
  else
@@ -58,6 +58,24 @@ module Bora
58
58
  config.select { |k| valid_options.include?(k) }
59
59
  end
60
60
 
61
+ def extract_params(stack_config, args)
62
+ params = stack_config['params'] || {}
63
+ params.merge!(extract_params_from_args(args.extras))
64
+ params.map { |k, v| [k, process_param_value(v)] }.to_h
65
+ end
66
+
67
+ def process_param_value(val)
68
+ old_val = nil
69
+ while old_val != val
70
+ old_val = val
71
+ val = val.sub(/\${[^}]+}/) do |m|
72
+ token = m[2..-2]
73
+ CfnParamResolver.new(token).resolve
74
+ end
75
+ end
76
+ val
77
+ end
78
+
61
79
  def extract_params_from_args(args)
62
80
  args ? Hash[args.map { |arg| arg.split("=", 2) }] : {}
63
81
  end
@@ -1,3 +1,3 @@
1
1
  module Bora
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Blaxland
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -125,6 +125,7 @@ files:
125
125
  - bin/setup
126
126
  - bora.gemspec
127
127
  - lib/bora.rb
128
+ - lib/bora/cfn_param_resolver.rb
128
129
  - lib/bora/event.rb
129
130
  - lib/bora/output.rb
130
131
  - lib/bora/rake_tasks.rb