sfn 2.1.10 → 2.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/bin/sfn +5 -1
- data/docs/commands.md +21 -0
- data/docs/configuration.md +4 -0
- data/lib/sfn/command/graph.rb +28 -2
- data/lib/sfn/command/update.rb +13 -10
- data/lib/sfn/command_module/template.rb +16 -1
- data/lib/sfn/config.rb +4 -2
- data/lib/sfn/config/graph.rb +12 -0
- data/lib/sfn/config/update.rb +10 -0
- 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: 1998884aef2f32da686903df01d5dbcd702e134d
|
4
|
+
data.tar.gz: 2d4cd76d833eaf5db2e3d05d69e815546d092b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c7021222f98ebbf2587d876172d02ee49e20c5eca73be13862ccb332c1674c4be34031963a69ff9dcf6739e9497e0d0ae4b8b778911d0e1b9e3946c350352c3
|
7
|
+
data.tar.gz: 30fbcb41c8291f6e77231c4c372d3a85d32dae4280a733efae28f64ab79bb966dc881dc7b52e5d11ed9e72343f4958d573b6289b166639a9f2126f7d76f77fdb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v2.1.12
|
2
|
+
* [fix] Provide useful error message when nesting_bucket is unset (#159)
|
3
|
+
* [fix] Properly locate templates when relative path provided (#160)
|
4
|
+
* [enhancement] Support plan only output on update via `--plan-only` (#158)
|
5
|
+
* [enhancement] Allow tag updates on stack updates via `--merge-api-options` (see: #154)
|
6
|
+
* [fix] Add `DependsOn` support to graph generation
|
7
|
+
* [enhancement] Provide "dependency" style graph option
|
8
|
+
|
1
9
|
# v2.1.10
|
2
10
|
* [fix] Prevent direct output key modification on graph mapping
|
3
11
|
* [enhancement] Restrict graph colors to readable values
|
data/bin/sfn
CHANGED
@@ -41,7 +41,11 @@ Bogo::Cli::Setup.define do
|
|
41
41
|
o[:delimiter] = nil
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
if(info[:short])
|
45
|
+
on info[:short], on_name, info[:description], opts
|
46
|
+
else
|
47
|
+
on on_name, info[:description], opts
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
run do |opts, args|
|
data/docs/commands.md
CHANGED
@@ -327,6 +327,27 @@ Example of stack diff:
|
|
327
327
|
|
328
328
|
![stack diff](./images/d_diff.png)
|
329
329
|
|
330
|
+
#### Template graphs
|
331
|
+
|
332
|
+
Creation or dependency graphs can be created via `sfn`. Two styles of the graph can be
|
333
|
+
generated:
|
334
|
+
|
335
|
+
* `"creation"` - Resource creation flow (default)
|
336
|
+
* `"dependency"` - Resource dependency composition
|
337
|
+
|
338
|
+
To generate a graph:
|
339
|
+
|
340
|
+
~~~
|
341
|
+
$ sfn graph --file my_template --graph-style dependency
|
342
|
+
~~~
|
343
|
+
|
344
|
+
By default the graph command will create a Graphviz compatible dot format file. If Graphviz
|
345
|
+
is installed on the local system, an image can be generated directly:
|
346
|
+
|
347
|
+
~~~
|
348
|
+
$ sfn graph --file my_template --graph-type png
|
349
|
+
~~~
|
350
|
+
|
330
351
|
### Configuration commands
|
331
352
|
|
332
353
|
To aid setup and configuration, `sfn` provides a configuration helper:
|
data/docs/configuration.md
CHANGED
@@ -77,6 +77,10 @@ $ knife sparkleformation --help
|
|
77
77
|
| | Valid | `Hash`
|
78
78
|
| | Default | none
|
79
79
|
|----------------------------|---------------|---------------------------------------------------------------
|
80
|
+
| `merge_api_options` | Description | Merges API options on stack update
|
81
|
+
| | Valid | `TrueClass`, `FalseClass`
|
82
|
+
| | Default | `false`
|
83
|
+
|----------------------------|---------------|---------------------------------------------------------------
|
80
84
|
| `ssh_attempt_users` | Description | List of users to attempt SSH connection on node failure
|
81
85
|
| | Valid | `Array<String>`
|
82
86
|
| | Default | none
|
data/lib/sfn/command/graph.rb
CHANGED
@@ -10,16 +10,23 @@ module Sfn
|
|
10
10
|
include Sfn::CommandModule::Template
|
11
11
|
include Sfn::CommandModule::Stack
|
12
12
|
|
13
|
+
# Valid graph styles
|
14
|
+
GRAPH_STYLES = [
|
15
|
+
'creation',
|
16
|
+
'dependency'
|
17
|
+
]
|
18
|
+
|
13
19
|
# Generate graph
|
14
20
|
def execute!
|
15
21
|
config[:print_only] = true
|
22
|
+
validate_graph_style!
|
16
23
|
file = load_template_file
|
17
24
|
file.delete('sfn_nested_stack')
|
18
25
|
file = Sfn::Utils::StackParameterScrubber.scrub!(file)
|
19
26
|
file = translate_template(file)
|
20
27
|
@outputs = Smash.new
|
21
28
|
file = file.to_smash
|
22
|
-
ui.info
|
29
|
+
ui.info "Template resource graph generation - Style: #{ui.color(config[:graph_style], :bold)}"
|
23
30
|
if(config[:file])
|
24
31
|
ui.puts " -> path: #{config[:file]}"
|
25
32
|
end
|
@@ -162,7 +169,11 @@ module Sfn
|
|
162
169
|
if(resources.keys.include?(dep_name))
|
163
170
|
dep_name = [node_prefix, dep_name].join
|
164
171
|
end
|
165
|
-
|
172
|
+
if(config[:graph_style] == 'creation')
|
173
|
+
@root_graph.edge(dep_name, node_name)
|
174
|
+
else
|
175
|
+
@root_graph.edge(node_name, dep_name)
|
176
|
+
end
|
166
177
|
end
|
167
178
|
end
|
168
179
|
resource_names.concat resources.keys.map{|r_name| [node_prefix, r_name].join}
|
@@ -174,6 +185,10 @@ module Sfn
|
|
174
185
|
data.map do |key, value|
|
175
186
|
if(key == 'Ref' && names.include?(value))
|
176
187
|
value
|
188
|
+
elsif(key == 'DependsOn')
|
189
|
+
[value].flatten.compact.find_all do |dependson_name|
|
190
|
+
names.include?(dependson_name)
|
191
|
+
end
|
177
192
|
elsif(key == 'Fn::GetAtt' && names.include?(res = [value].flatten.compact.first))
|
178
193
|
res
|
179
194
|
else
|
@@ -211,6 +226,17 @@ module Sfn
|
|
211
226
|
color
|
212
227
|
end
|
213
228
|
|
229
|
+
def validate_graph_style!
|
230
|
+
if(config[:luckymike])
|
231
|
+
ui.warn 'Detected luckymike power override. Forcing `dependency` style!'
|
232
|
+
config[:graph_style] = 'dependency'
|
233
|
+
end
|
234
|
+
config[:graph_style] = config[:graph_style].to_s
|
235
|
+
unless(GRAPH_STYLES.include?(config[:graph_style]))
|
236
|
+
raise ArgumentError.new "Invalid graph style provided `#{config[:graph_style]}`. Valid: `#{GRAPH_STYLES.join('`, `')}`"
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
214
240
|
class GraphProcessor < SparkleFormation::Translation
|
215
241
|
MAP = {}
|
216
242
|
REF_MAPPING = {}
|
data/lib/sfn/command/update.rb
CHANGED
@@ -99,30 +99,33 @@ module Sfn
|
|
99
99
|
unless(e.message.include?('Confirmation declined'))
|
100
100
|
ui.error "Unexpected error when generating plan information: #{e.class} - #{e}"
|
101
101
|
ui.debug "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
|
102
|
-
ui.confirm 'Continue with stack update?'
|
102
|
+
ui.confirm 'Continue with stack update?' unless config[:plan_only]
|
103
103
|
else
|
104
104
|
raise
|
105
105
|
end
|
106
106
|
end
|
107
|
+
if(config[:plan_only])
|
108
|
+
ui.info 'Plan only mode requested. Exiting.'
|
109
|
+
exit 0
|
110
|
+
end
|
107
111
|
end
|
108
112
|
|
109
113
|
stack.parameters = config_root_parameters
|
110
114
|
stack.template = scrub_template(update_template)
|
111
115
|
else
|
112
116
|
apply_stacks!(stack)
|
113
|
-
|
114
117
|
original_parameters = stack.parameters
|
115
118
|
populate_parameters!(stack.template, :current_parameters => stack.parameters)
|
119
|
+
stack.parameters = config_root_parameters
|
120
|
+
end
|
116
121
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
if(
|
121
|
-
|
122
|
-
display_plan_information(result)
|
122
|
+
# Set options defined within config into stack instance for update request
|
123
|
+
if(config[:merge_api_options])
|
124
|
+
config.fetch(:options, Smash.new).each_pair do |key, value|
|
125
|
+
if(stack.respond_to?("#{key}="))
|
126
|
+
stack.send("#{key}=", value)
|
123
127
|
end
|
124
128
|
end
|
125
|
-
stack.parameters = config_root_parameters
|
126
129
|
end
|
127
130
|
|
128
131
|
begin
|
@@ -168,7 +171,7 @@ module Sfn
|
|
168
171
|
unless(print_plan_result(result))
|
169
172
|
ui.info 'No resources life cycle changes detected in this update!'
|
170
173
|
end
|
171
|
-
ui.confirm 'Apply this stack update?'
|
174
|
+
ui.confirm 'Apply this stack update?' unless config[:plan_only]
|
172
175
|
end
|
173
176
|
|
174
177
|
|
@@ -180,6 +180,7 @@ module Sfn
|
|
180
180
|
end
|
181
181
|
run_callbacks_for(:template, :stack_name => arguments.first, :sparkle_stack => sf)
|
182
182
|
if(sf.nested? && config[:apply_nesting])
|
183
|
+
validate_nesting_bucket!
|
183
184
|
if(config[:apply_nesting] == true)
|
184
185
|
config[:apply_nesting] = :deep
|
185
186
|
end
|
@@ -206,6 +207,14 @@ module Sfn
|
|
206
207
|
end
|
207
208
|
end
|
208
209
|
|
210
|
+
# Force user friendly error if nesting bucket is not set within configuration
|
211
|
+
def validate_nesting_bucket!
|
212
|
+
if(config[:nesting_bucket].to_s.empty?)
|
213
|
+
ui.error 'Missing required configuration value for `nesting_bucket`. Cannot generated nested templates!'
|
214
|
+
raise ArgumentError.new 'Required configuration value for `nesting_bucket` not provided.'
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
209
218
|
# Processes template using the original shallow workflow
|
210
219
|
#
|
211
220
|
# @param sf [SparkleFormation] stack formation
|
@@ -406,7 +415,13 @@ module Sfn
|
|
406
415
|
if(!config[:file] && config[:file_path_prompt])
|
407
416
|
config[:file] = prompt_for_template
|
408
417
|
else
|
409
|
-
|
418
|
+
file_lookup_path = File.expand_path(config[:file])
|
419
|
+
unless(File.exists?(file_lookup_path))
|
420
|
+
file_lookup_path = config[:file]
|
421
|
+
end
|
422
|
+
config[:file] = sparkle_collection.get(
|
423
|
+
:template, file_lookup_path
|
424
|
+
)[:path]
|
410
425
|
end
|
411
426
|
else
|
412
427
|
if(config[:file])
|
data/lib/sfn/config.rb
CHANGED
@@ -142,8 +142,10 @@ module Sfn
|
|
142
142
|
if(!short.to_s.empty? && shorts.include?(short))
|
143
143
|
raise ArgumentError.new "Short flag already in use! (`#{short}` not available for `#{klass}`)"
|
144
144
|
end
|
145
|
-
|
146
|
-
|
145
|
+
unless(short.to_s.empty?)
|
146
|
+
shorts << short
|
147
|
+
info[:short] = short
|
148
|
+
end
|
147
149
|
info[:long] = name.tr('_', '-')
|
148
150
|
info[:boolean] = [info[:type]].compact.flatten.all?{|t| BOOLEAN_VALUES.include?(t)}
|
149
151
|
[name, info]
|
data/lib/sfn/config/graph.rb
CHANGED
@@ -19,6 +19,18 @@ module Sfn
|
|
19
19
|
:default => 'dot'
|
20
20
|
)
|
21
21
|
|
22
|
+
attribute(
|
23
|
+
:graph_style, String,
|
24
|
+
:description => 'Style of graph (`dependency`, `creation`)',
|
25
|
+
:default => 'creation'
|
26
|
+
)
|
27
|
+
|
28
|
+
attribute(
|
29
|
+
:luckymike, [TrueClass, FalseClass],
|
30
|
+
:description => 'Force `dependency` style graph',
|
31
|
+
:default => false
|
32
|
+
)
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
data/lib/sfn/config/update.rb
CHANGED
@@ -40,11 +40,21 @@ module Sfn
|
|
40
40
|
:description => 'Provide planning information prior to update',
|
41
41
|
:short_flag => 'l'
|
42
42
|
)
|
43
|
+
attribute(
|
44
|
+
:plan_only, [TrueClass, FalseClass],
|
45
|
+
:default => false,
|
46
|
+
:description => 'Exit after plan display'
|
47
|
+
)
|
43
48
|
attribute(
|
44
49
|
:diffs, [TrueClass, FalseClass],
|
45
50
|
:description => 'Show planner content diff',
|
46
51
|
:short_flag => 'D'
|
47
52
|
)
|
53
|
+
attribute(
|
54
|
+
:merge_api_options, [TrueClass, FalseClass],
|
55
|
+
:description => 'Merge API options defined within configuration on update',
|
56
|
+
:default => false
|
57
|
+
)
|
48
58
|
|
49
59
|
end
|
50
60
|
end
|
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: 2.1.
|
4
|
+
version: 2.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|