bora 0.9.1 → 0.9.2
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/lib/bora/cfn_param_resolver.rb +22 -0
- data/lib/bora/output.rb +8 -0
- data/lib/bora/rake_tasks.rb +20 -2
- data/lib/bora/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea4493a9644738e50bf62a8083150dfc6f1aa76e
|
4
|
+
data.tar.gz: c32798fe76ef04770c196b5700e406b1c6f6e1e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/bora/output.rb
CHANGED
@@ -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}"
|
data/lib/bora/rake_tasks.rb
CHANGED
@@ -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
|
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
|
data/lib/bora/version.rb
CHANGED
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.
|
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-
|
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
|