sfn 3.0.24 → 3.0.26
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/CHANGELOG.md +8 -0
- data/lib/sfn/callback/stack_policy.rb +1 -1
- data/lib/sfn/command/graph.rb +36 -30
- data/lib/sfn/command/update.rb +10 -8
- data/lib/sfn/command_module/template.rb +52 -42
- data/lib/sfn/monkey_patch/stack.rb +1 -1
- data/lib/sfn/planner/aws.rb +6 -1
- data/lib/sfn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1000514f95a36a106dc13fd6eaf7a38a9e716776
|
4
|
+
data.tar.gz: fc0d733bafcd09198a2a56252c574956ded1ae22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ef25e6f6722a338b428d5707dde1912d0c94a8c3adab30a297fe9ad830f0cbc415eff1130e3f824bcc0d46bd2f6e423259595f6093486dd3efe51d50e8d801c
|
7
|
+
data.tar.gz: a179f76dd94173102a5e6d07fb20e91a4f689b21a02a6d79024d09bc10c373dee37403f8e15e7152692642de738c457039d76523c9a5c693408e195df8e2b4dc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v3.0.26
|
2
|
+
* [fix] Properly support compile time parameter setting with/without stack name (#261)
|
3
|
+
* [fix] Default stack name when storing policy internally if no name provided
|
4
|
+
* [fix] Apply stack parameters via accessor on update so changes are detected properly
|
5
|
+
* [fix] Prevent planner from splitting non-String values
|
6
|
+
* [fix] Process template through grapher as dumped Hash, error on non-AWS providers
|
7
|
+
* [enhancement] Support processing complex compile time parameter types
|
8
|
+
|
1
9
|
# v3.0.24
|
2
10
|
* [fix] Quieter print only output (#258)
|
3
11
|
* [fix] Require all modules for lint (#248)
|
data/lib/sfn/command/graph.rb
CHANGED
@@ -21,34 +21,40 @@ module Sfn
|
|
21
21
|
config[:print_only] = true
|
22
22
|
validate_graph_style!
|
23
23
|
file = load_template_file
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
run_action 'Pre-processing template for graphing' do
|
30
|
-
output_discovery(file, @outputs, nil, nil)
|
31
|
-
ui.debug 'Output remapping results from pre-processing:'
|
32
|
-
@outputs.each_pair do |o_key, o_value|
|
33
|
-
ui.debug "#{o_key} -> #{o_value}"
|
24
|
+
if(file.provider == :aws)
|
25
|
+
@outputs = Smash.new
|
26
|
+
ui.info "Template resource graph generation - Style: #{ui.color(config[:graph_style], :bold)}"
|
27
|
+
if(config[:file])
|
28
|
+
ui.puts " -> path: #{config[:file]}"
|
34
29
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
run_action 'Writing graph result' do
|
43
|
-
FileUtils.mkdir_p(File.dirname(config[:output_file]))
|
44
|
-
if(config[:output_type] == 'dot')
|
45
|
-
File.open("#{config[:output_file]}.dot", 'w') do |o_file|
|
46
|
-
o_file.puts graph.to_s
|
30
|
+
template_dump = file.compile.dump!.to_smash
|
31
|
+
run_action 'Pre-processing template for graphing' do
|
32
|
+
output_discovery(template_dump, @outputs, nil, nil)
|
33
|
+
ui.debug 'Output remapping results from pre-processing:'
|
34
|
+
@outputs.each_pair do |o_key, o_value|
|
35
|
+
ui.debug "#{o_key} -> #{o_value}"
|
47
36
|
end
|
48
|
-
|
49
|
-
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
graph = nil
|
40
|
+
run_action 'Generating resource graph' do
|
41
|
+
graph = generate_graph(template_dump)
|
42
|
+
nil
|
50
43
|
end
|
51
|
-
|
44
|
+
run_action 'Writing graph result' do
|
45
|
+
FileUtils.mkdir_p(File.dirname(config[:output_file]))
|
46
|
+
if(config[:output_type] == 'dot')
|
47
|
+
File.open("#{config[:output_file]}.dot", 'w') do |o_file|
|
48
|
+
o_file.puts graph.to_s
|
49
|
+
end
|
50
|
+
else
|
51
|
+
graph.save config[:output_file], config[:output_type]
|
52
|
+
end
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
else
|
56
|
+
ui.error "Graphing for provider `#{file.provider}` not currently supported."
|
57
|
+
ui.error "Currently supported providers: `aws`."
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
@@ -72,11 +78,11 @@ module Sfn
|
|
72
78
|
end
|
73
79
|
|
74
80
|
def output_discovery(template, outputs, resource_name, parent_template, name='')
|
75
|
-
|
76
|
-
template.
|
77
|
-
r_info = template
|
78
|
-
if(r_info
|
79
|
-
output_discovery(r_info
|
81
|
+
if(template['Resources'])
|
82
|
+
template['Resources'].keys.each do |r_name|
|
83
|
+
r_info = template['Resources'][r_name]
|
84
|
+
if(r_info['Type'] == 'AWS::CloudFormation::Stack')
|
85
|
+
output_discovery(r_info['Properties']['Stack'], outputs, r_name, template, r_name)
|
80
86
|
end
|
81
87
|
end
|
82
88
|
end
|
data/lib/sfn/command/update.rb
CHANGED
@@ -51,6 +51,8 @@ module Sfn
|
|
51
51
|
ui.debug "Compile parameters - #{config[:compile_parameters]}"
|
52
52
|
file = load_template_file(:stack => stack)
|
53
53
|
stack_info << " #{ui.color('Path:', :bold)} #{config[:file]}"
|
54
|
+
else
|
55
|
+
file = stack.template.dup if config[:plan]
|
54
56
|
end
|
55
57
|
|
56
58
|
unless(stack)
|
@@ -114,20 +116,20 @@ module Sfn
|
|
114
116
|
end
|
115
117
|
end
|
116
118
|
stack.parameters = config_root_parameters
|
119
|
+
|
120
|
+
if(config[:upload_root_template])
|
121
|
+
upload_result = store_template(name, file, Smash.new)
|
122
|
+
stack.template_url = upload_result[:url]
|
123
|
+
else
|
124
|
+
stack.template = parameter_scrub!(template_content(file, :scrub))
|
125
|
+
end
|
117
126
|
else
|
118
127
|
apply_stacks!(stack)
|
119
128
|
original_parameters = stack.parameters
|
120
|
-
populate_parameters!(
|
129
|
+
populate_parameters!(stack.template, :current_parameters => stack.root_parameters)
|
121
130
|
stack.parameters = config_root_parameters
|
122
131
|
end
|
123
132
|
|
124
|
-
if(config[:upload_root_template])
|
125
|
-
upload_result = store_template(name, file, Smash.new)
|
126
|
-
stack.template_url = upload_result[:url]
|
127
|
-
else
|
128
|
-
stack.template = parameter_scrub!(template_content(file, :scrub))
|
129
|
-
end
|
130
|
-
|
131
133
|
# Set options defined within config into stack instance for update request
|
132
134
|
if(config[:merge_api_options])
|
133
135
|
config.fetch(:options, Smash.new).each_pair do |key, value|
|
@@ -48,57 +48,67 @@ module Sfn
|
|
48
48
|
def request_compile_parameter(p_name, p_config, cur_val, nested=false)
|
49
49
|
result = nil
|
50
50
|
attempts = 0
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
until(result && (!result.respond_to?(:empty?) || !result.empty?))
|
58
|
-
attempts += 1
|
59
|
-
if(config[:interactive_parameters] && (!nested || !p_config.key?(:prompt_when_nested) || p_config[:prompt_when_nested] == true))
|
60
|
-
result = ui.ask_question(
|
61
|
-
p_name.to_s.split('_').map(&:capitalize).join,
|
62
|
-
:default => cur_val.to_s.empty? ? nil : cur_val.to_s
|
63
|
-
)
|
51
|
+
parameter_type = p_config.fetch(:type, 'string').to_s.downcase.to_sym
|
52
|
+
if(parameter_type == :complex)
|
53
|
+
ui.debug "Compile time parameter `#{p_name}` is a complex type. Not requesting value from user."
|
54
|
+
if(cur_val.nil?)
|
55
|
+
raise ArgumentError.new "No value provided for `#{p_name}` parameter (Complex data type)"
|
64
56
|
else
|
65
|
-
|
57
|
+
cur_val
|
58
|
+
end
|
59
|
+
else
|
60
|
+
unless(cur_val || p_config[:default].nil?)
|
61
|
+
cur_val = p_config[:default]
|
62
|
+
end
|
63
|
+
if(cur_val.is_a?(Array))
|
64
|
+
cur_val = cur_val.map(&:to_s).join(',')
|
66
65
|
end
|
67
|
-
|
68
|
-
|
69
|
-
if(p_config[:
|
70
|
-
result =
|
66
|
+
until(result && (!result.respond_to?(:empty?) || !result.empty?))
|
67
|
+
attempts += 1
|
68
|
+
if(config[:interactive_parameters] && (!nested || !p_config.key?(:prompt_when_nested) || p_config[:prompt_when_nested] == true))
|
69
|
+
result = ui.ask_question(
|
70
|
+
p_name.to_s.split('_').map(&:capitalize).join,
|
71
|
+
:default => cur_val.to_s.empty? ? nil : cur_val.to_s
|
72
|
+
)
|
73
|
+
else
|
74
|
+
result = cur_val.to_s
|
71
75
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
case parameter_type
|
77
|
+
when :string
|
78
|
+
if(p_config[:multiple])
|
79
|
+
result = result.split(',').map(&:strip)
|
80
|
+
end
|
81
|
+
when :number
|
82
|
+
if(p_config[:multiple])
|
83
|
+
result = result.split(',').map(&:strip)
|
84
|
+
new_result = result.map do |item|
|
85
|
+
new_item = item.to_i
|
86
|
+
new_item if new_item.to_s == item
|
87
|
+
end
|
88
|
+
result = new_result.size == result.size ? new_result : []
|
89
|
+
else
|
90
|
+
new_result = result.to_i
|
91
|
+
result = new_result.to_s == result ? new_result : nil
|
78
92
|
end
|
79
|
-
result = new_result.size == result.size ? new_result : []
|
80
93
|
else
|
81
|
-
|
82
|
-
result = new_result.to_s == result ? new_result : nil
|
94
|
+
raise ArgumentError.new "Unknown compile time parameter type provided: `#{p_config[:type].inspect}` (Parameter: #{p_name})"
|
83
95
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
valid.each do |invalid_msg|
|
91
|
-
ui.error invalid_msg.last
|
96
|
+
valid = validate_parameter(result, p_config.to_smash)
|
97
|
+
unless(valid == true)
|
98
|
+
result = nil
|
99
|
+
valid.each do |invalid_msg|
|
100
|
+
ui.error invalid_msg.last
|
101
|
+
end
|
92
102
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
103
|
+
if(result.nil? || (result.respond_to?(:empty?) && result.empty?))
|
104
|
+
if(attempts > MAX_PARAMETER_ATTEMPTS)
|
105
|
+
ui.fatal "Failed to receive allowed parameter! (Parameter: #{p_name})"
|
106
|
+
exit 1
|
107
|
+
end
|
98
108
|
end
|
99
109
|
end
|
110
|
+
result
|
100
111
|
end
|
101
|
-
result
|
102
112
|
end
|
103
113
|
|
104
114
|
# @return [Array<SparkleFormation::SparklePack>]
|
@@ -253,7 +263,7 @@ module Sfn
|
|
253
263
|
ui.debug "Initial compile parameters - #{compile_state}"
|
254
264
|
compile_state.keys.each do |cs_key|
|
255
265
|
unless(cs_key.to_s.start_with?("#{arguments.first}__"))
|
256
|
-
named_cs_key =
|
266
|
+
named_cs_key = [arguments.first, cs_key].compact.join('__')
|
257
267
|
non_named = compile_state.delete(cs_key)
|
258
268
|
if(non_named && !compile_state.key?(named_cs_key))
|
259
269
|
ui.debug "Setting non-named compile parameter `#{cs_key}` into `#{named_cs_key}`"
|
data/lib/sfn/planner/aws.rb
CHANGED
@@ -169,7 +169,12 @@ module Sfn
|
|
169
169
|
# @param value [Array<String,Array<String>>]
|
170
170
|
# @return [String]
|
171
171
|
def fn_join(value)
|
172
|
-
value.last.
|
172
|
+
unless(value.last.is_a?(Array))
|
173
|
+
val = value.last.to_s.split(',')
|
174
|
+
else
|
175
|
+
val = value.last
|
176
|
+
end
|
177
|
+
val.join(value.first)
|
173
178
|
end
|
174
179
|
|
175
180
|
# Lookup value in mappings
|
data/lib/sfn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|