sfn 3.1.0 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/sfn/command.rb +1 -0
- data/lib/sfn/command/destroy.rb +9 -4
- data/lib/sfn/command/trace.rb +52 -0
- data/lib/sfn/command_module/template.rb +11 -6
- data/lib/sfn/config.rb +1 -0
- data/lib/sfn/config/print.rb +1 -1
- data/lib/sfn/config/trace.rb +9 -0
- data/lib/sfn/planner/aws.rb +4 -4
- data/lib/sfn/provider.rb +9 -1
- data/lib/sfn/version.rb +1 -1
- data/sfn.gemspec +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0d3ba5a54ddc491d9a7dc4acc98baf4cd3e9533fe9e6dfb74e4154603566a2
|
4
|
+
data.tar.gz: bb96f40718dac5aaf5ea8e3b3de04afac2bcf893a5f3108c44d6023435d86234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01657ee293977a4f07e745d53b426ebc723f056892b4df6cd6f850e2361435521df969bd6cf081cbb9f0ca45ca5fe6764f5763369e59aab3c611794a34dea2ff
|
7
|
+
data.tar.gz: 90648c378bae5ac67ee578e41dcba9fa6ac1cd529fa34362dc8a758ce33336df74611adf27b1ec2bf16dc0a86f624f03ae4159a11952a4888f5b5fac1ded1224
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v3.1.2
|
2
|
+
* [feature] Add `trace` command for template composition inspection (#289)
|
3
|
+
* [fix] Return non-zero exit code when polling stack destroy fails (#292)
|
4
|
+
* [fix] Update planner to handle value re-order (#290)
|
5
|
+
|
1
6
|
# v3.1.0
|
2
7
|
* [enhancement] Split `plan` command into `plan` and `realize` (#285)
|
3
8
|
* [deprecation] Remove sfn command mapping knife integration (#286)
|
data/lib/sfn/command.rb
CHANGED
@@ -22,6 +22,7 @@ module Sfn
|
|
22
22
|
autoload :Print, "sfn/command/print"
|
23
23
|
autoload :Promote, "sfn/command/promote"
|
24
24
|
autoload :Realize, "sfn/command/realize"
|
25
|
+
autoload :Trace, "sfn/command/trace"
|
25
26
|
autoload :Update, "sfn/command/update"
|
26
27
|
autoload :Validate, "sfn/command/validate"
|
27
28
|
|
data/lib/sfn/command/destroy.rb
CHANGED
@@ -45,12 +45,17 @@ module Sfn
|
|
45
45
|
end
|
46
46
|
if config[:poll]
|
47
47
|
if stacks.size == 1
|
48
|
+
pstack = stacks.first
|
48
49
|
begin
|
49
|
-
poll_stack(
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
poll_stack(pstack)
|
51
|
+
stack = provider.connection.stacks.get(pstack)
|
52
|
+
stack.reload
|
53
|
+
if stack.state.to_s.end_with?("failed")
|
54
|
+
ui.error("Stack #{ui.color(pstack, :bold)} still exists after polling complete.")
|
55
|
+
raise "Failed to successfully destroy stack!"
|
53
56
|
end
|
57
|
+
rescue Miasma::Error::ApiError::RequestError => error
|
58
|
+
# Ignore if stack cannot be reloaded
|
54
59
|
end
|
55
60
|
else
|
56
61
|
ui.error "Stack polling is not available when multiple stack deletion is requested!"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "sparkle_formation"
|
2
|
+
require "sfn"
|
3
|
+
|
4
|
+
module Sfn
|
5
|
+
class Command
|
6
|
+
# Trace command
|
7
|
+
class Trace < Command
|
8
|
+
include Sfn::CommandModule::Base
|
9
|
+
include Sfn::CommandModule::Template
|
10
|
+
include Sfn::CommandModule::Stack
|
11
|
+
|
12
|
+
# Print the requested template
|
13
|
+
def execute!
|
14
|
+
config[:sparkle_dump] = true
|
15
|
+
config[:print_only] = true
|
16
|
+
file = load_template_file
|
17
|
+
|
18
|
+
if !file.is_a?(SparkleFormation)
|
19
|
+
raise "Cannot trace non-SparkleFormation template"
|
20
|
+
else
|
21
|
+
writer = proc do |audit_log, indent = ""|
|
22
|
+
audit_log.each do |record|
|
23
|
+
header = "#{indent}-> "
|
24
|
+
header << ui.color(record.type.to_s.capitalize, :bold)
|
25
|
+
header << " - #{record.name}"
|
26
|
+
source = "#{indent} | source: "
|
27
|
+
if record.location.line > 0
|
28
|
+
source << "#{record.location.path} @ #{record.location.line}"
|
29
|
+
else
|
30
|
+
source << ui.color(record.location.path, :yellow)
|
31
|
+
end
|
32
|
+
origin = "#{indent} | caller: "
|
33
|
+
if record.caller.line > 0
|
34
|
+
origin << "#{record.caller.path} @ #{record.caller.line}"
|
35
|
+
else
|
36
|
+
origin << ui.color(record.caller.path, :yellow)
|
37
|
+
end
|
38
|
+
ui.info header
|
39
|
+
ui.info source
|
40
|
+
ui.info origin
|
41
|
+
if record.audit_log.count > 0
|
42
|
+
writer.call(record.audit_log, indent + " |")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
ui.info ui.color("Trace information:", :bold)
|
47
|
+
writer.call(file.audit_log)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -48,6 +48,7 @@ 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
|
+
ui.debug "Fetching compile time param named #{p_name}"
|
51
52
|
parameter_type = p_config.fetch(:type, "string").to_s.downcase.to_sym
|
52
53
|
if parameter_type == :complex
|
53
54
|
ui.debug "Compile time parameter `#{p_name}` is a complex type. Not requesting value from user."
|
@@ -178,11 +179,11 @@ module Sfn
|
|
178
179
|
config[:template]
|
179
180
|
elsif config[:file]
|
180
181
|
if config[:processing]
|
181
|
-
compile_state = merge_compile_time_parameters
|
182
182
|
sf = SparkleFormation.compile(config[:file], :sparkle)
|
183
183
|
if name_args.first
|
184
184
|
sf.name = name_args.first
|
185
185
|
end
|
186
|
+
compile_state = merge_compile_time_parameters(sf.root?)
|
186
187
|
sf.compile_time_parameter_setter do |formation|
|
187
188
|
f_name = formation.root_path.map(&:name).map(&:to_s)
|
188
189
|
pathed_name = f_name.join(" > ")
|
@@ -257,13 +258,17 @@ module Sfn
|
|
257
258
|
|
258
259
|
# Merge parameters provided directly via configuration into
|
259
260
|
# core parameter set
|
260
|
-
def merge_compile_time_parameters
|
261
|
+
def merge_compile_time_parameters(root_template = false)
|
261
262
|
compile_state = config.fetch(:compile_parameters, Smash.new)
|
262
263
|
ui.debug "Initial compile parameters - #{compile_state}"
|
263
264
|
compile_state.keys.each do |cs_key|
|
264
265
|
unless cs_key.to_s.start_with?("#{arguments.first}__")
|
265
266
|
named_cs_key = [arguments.first, cs_key].compact.join("__")
|
266
|
-
|
267
|
+
if root_template
|
268
|
+
non_named = compile_state[cs_key]
|
269
|
+
else
|
270
|
+
non_named = compile_state.delete(cs_key)
|
271
|
+
end
|
267
272
|
if non_named && !compile_state.key?(named_cs_key)
|
268
273
|
ui.debug "Setting non-named compile parameter `#{cs_key}` into `#{named_cs_key}`"
|
269
274
|
compile_state[named_cs_key] = non_named
|
@@ -295,12 +300,12 @@ module Sfn
|
|
295
300
|
def process_nested_stack_shallow(sf, c_stack = nil)
|
296
301
|
sf.apply_nesting(:shallow) do |stack_name, stack, resource|
|
297
302
|
run_callbacks_for(:template, :stack_name => stack_name, :sparkle_stack => stack)
|
298
|
-
bucket = provider.connection.api_for(:storage).buckets.get(
|
299
|
-
config[:nesting_bucket]
|
300
|
-
)
|
301
303
|
if config[:print_only]
|
302
304
|
template_url = "http://example.com/bucket/#{name_args.first}_#{stack_name}.json"
|
303
305
|
else
|
306
|
+
bucket = provider.connection.api_for(:storage).buckets.get(
|
307
|
+
config[:nesting_bucket]
|
308
|
+
)
|
304
309
|
stack_definition = dump_stack_for_storage(stack)
|
305
310
|
unless bucket
|
306
311
|
raise "Failed to locate configured bucket for stack template storage (#{bucket})!"
|
data/lib/sfn/config.rb
CHANGED
@@ -60,6 +60,7 @@ module Sfn
|
|
60
60
|
autoload :Print, "sfn/config/print"
|
61
61
|
autoload :Promote, "sfn/config/promote"
|
62
62
|
autoload :Realize, "sfn/config/realize"
|
63
|
+
autoload :Trace, "sfn/config/trace"
|
63
64
|
autoload :Update, "sfn/config/update"
|
64
65
|
autoload :Validate, "sfn/config/validate"
|
65
66
|
|
data/lib/sfn/config/print.rb
CHANGED
data/lib/sfn/planner/aws.rb
CHANGED
@@ -512,10 +512,10 @@ module Sfn
|
|
512
512
|
def diff_init(diff, path)
|
513
513
|
Smash.new.tap do |di|
|
514
514
|
if diff.size > 1
|
515
|
-
updated = diff.
|
516
|
-
original = diff.
|
517
|
-
di[:original] = original.last.
|
518
|
-
di[:updated] = updated.last.
|
515
|
+
updated = diff.find_all { |x| x.first == "+" }
|
516
|
+
original = diff.find_all { |x| x.first == "-" }
|
517
|
+
di[:original] = Array(original).map(&:last).join(", ")
|
518
|
+
di[:updated] = Array(updated).map(&:last).join(", ")
|
519
519
|
else
|
520
520
|
diff_data = diff.first
|
521
521
|
di[:path] = path
|
data/lib/sfn/provider.rb
CHANGED
@@ -101,7 +101,15 @@ module Sfn
|
|
101
101
|
fetch_stacks(stack_id) if recache
|
102
102
|
end
|
103
103
|
value = cache[:stacks].value
|
104
|
-
|
104
|
+
if value
|
105
|
+
value = MultiJson.load(value)
|
106
|
+
if value.respond_to?(:values)
|
107
|
+
value = value.values
|
108
|
+
end
|
109
|
+
MultiJson.dump(value)
|
110
|
+
else
|
111
|
+
"[]"
|
112
|
+
end
|
105
113
|
end
|
106
114
|
|
107
115
|
# @return [Miasma::Orchestration::Stack, NilClass]
|
data/lib/sfn/version.rb
CHANGED
data/sfn.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "miasma-terraform", ">= 0.1.0", "< 0.2.0"
|
22
22
|
s.add_runtime_dependency "jmespath"
|
23
23
|
s.add_runtime_dependency "net-ssh"
|
24
|
-
s.add_runtime_dependency "sparkle_formation", ">= 3.0.
|
24
|
+
s.add_runtime_dependency "sparkle_formation", ">= 3.0.35", "< 4"
|
25
25
|
s.add_runtime_dependency "hashdiff", "~> 0.2.2"
|
26
26
|
s.add_runtime_dependency "graph", "~> 2.8.1"
|
27
27
|
s.add_development_dependency "rake", "~> 10"
|
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.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|
@@ -224,7 +224,7 @@ dependencies:
|
|
224
224
|
requirements:
|
225
225
|
- - ">="
|
226
226
|
- !ruby/object:Gem::Version
|
227
|
-
version: 3.0.
|
227
|
+
version: 3.0.35
|
228
228
|
- - "<"
|
229
229
|
- !ruby/object:Gem::Version
|
230
230
|
version: '4'
|
@@ -234,7 +234,7 @@ dependencies:
|
|
234
234
|
requirements:
|
235
235
|
- - ">="
|
236
236
|
- !ruby/object:Gem::Version
|
237
|
-
version: 3.0.
|
237
|
+
version: 3.0.35
|
238
238
|
- - "<"
|
239
239
|
- !ruby/object:Gem::Version
|
240
240
|
version: '4'
|
@@ -420,6 +420,7 @@ files:
|
|
420
420
|
- lib/sfn/command/print.rb
|
421
421
|
- lib/sfn/command/promote.rb
|
422
422
|
- lib/sfn/command/realize.rb
|
423
|
+
- lib/sfn/command/trace.rb
|
423
424
|
- lib/sfn/command/update.rb
|
424
425
|
- lib/sfn/command/validate.rb
|
425
426
|
- lib/sfn/command_module.rb
|
@@ -446,6 +447,7 @@ files:
|
|
446
447
|
- lib/sfn/config/print.rb
|
447
448
|
- lib/sfn/config/promote.rb
|
448
449
|
- lib/sfn/config/realize.rb
|
450
|
+
- lib/sfn/config/trace.rb
|
449
451
|
- lib/sfn/config/update.rb
|
450
452
|
- lib/sfn/config/validate.rb
|
451
453
|
- lib/sfn/error.rb
|
@@ -491,8 +493,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
491
493
|
- !ruby/object:Gem::Version
|
492
494
|
version: '0'
|
493
495
|
requirements: []
|
494
|
-
|
495
|
-
rubygems_version: 2.7.6
|
496
|
+
rubygems_version: 3.0.1
|
496
497
|
signing_key:
|
497
498
|
specification_version: 4
|
498
499
|
summary: SparkleFormation CLI
|