sfn 0.4.16 → 0.5.0
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 +3 -0
- data/lib/sfn/command/update.rb +27 -1
- data/lib/sfn/command_module/template.rb +91 -4
- data/lib/sfn/version.rb +1 -1
- data/sfn.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3673b71af607d02ac346e2419e0f3ee10d29e7fb
|
4
|
+
data.tar.gz: 43fd1549a7deed286de8a4c59b9c1b3148700d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e47a279dc5d53e18674281d2371f0cd72539dd797d2a0e0276813125acc8118ee5087e96278b2bdf960f42147fda969bf1ab855c4b1b5b5f7532a6d85e62e46
|
7
|
+
data.tar.gz: 28ab80f21ef727f319a7c5c3ac685ced8f33c7fadcc5e680b444812957734c49cf13e30d27e18d0944004d91d5065e79b71c9135dbb6df58d6f7f075fa8bc090
|
data/CHANGELOG.md
CHANGED
data/lib/sfn/command/update.rb
CHANGED
@@ -18,8 +18,34 @@ module Sfn
|
|
18
18
|
end
|
19
19
|
|
20
20
|
stack_info = "#{ui.color('Name:', :bold)} #{name}"
|
21
|
+
stack = provider.connection.stacks.get(name)
|
22
|
+
|
23
|
+
config[:compile_parameters] ||= Smash.new
|
21
24
|
|
22
25
|
if(config[:file])
|
26
|
+
s_name = [name]
|
27
|
+
c_setter = lambda do |c_stack|
|
28
|
+
compile_params = c_stack.outputs.detect do |output|
|
29
|
+
output.key == 'CompileState'
|
30
|
+
end
|
31
|
+
if(compile_params)
|
32
|
+
compile_params = MultiJson.load(compile_params.value)
|
33
|
+
c_current = config[:compile_parameters].fetch(s_name.join('_'), Smash.new)
|
34
|
+
config[:compile_parameters][s_name.join('_')] = compile_params.merge(c_current)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if(stack)
|
39
|
+
c_setter.call(stack)
|
40
|
+
stack.resources.all.each do |s_resource|
|
41
|
+
if(s_resource.type == 'AWS::CloudFormation::Stack')
|
42
|
+
s_name.push(s_resource.logical_id)
|
43
|
+
c_setter.call(s_resource.expand)
|
44
|
+
s_name.pop
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
23
49
|
file = load_template_file
|
24
50
|
stack_info << " #{ui.color('Path:', :bold)} #{config[:file]}"
|
25
51
|
nested_stacks = file.delete('sfn_nested_stack')
|
@@ -61,7 +87,7 @@ module Sfn
|
|
61
87
|
begin
|
62
88
|
stack.save
|
63
89
|
rescue Miasma::Error::ApiError::RequestError => e
|
64
|
-
if(e.message.downcase.include?('no updates'))
|
90
|
+
if(e.message.downcase.include?('no updates'))
|
65
91
|
ui.warn "No updates detected for stack (#{stack.name})"
|
66
92
|
else
|
67
93
|
raise
|
@@ -10,9 +10,73 @@ module Sfn
|
|
10
10
|
|
11
11
|
# cloudformation directories that should be ignored
|
12
12
|
TEMPLATE_IGNORE_DIRECTORIES = %w(components dynamics registry)
|
13
|
+
# maximum number of attempts to get valid parameter value
|
14
|
+
MAX_PARAMETER_ATTEMPTS = 5
|
13
15
|
|
14
16
|
module InstanceMethods
|
15
17
|
|
18
|
+
# Request compile time parameter value
|
19
|
+
#
|
20
|
+
# @param p_name [String, Symbol] name of parameter
|
21
|
+
# @param p_config [Hash] parameter meta information
|
22
|
+
# @param cur_val [Object, NilClass] current value assigned to parameter
|
23
|
+
# @param nested [TrueClass, FalseClass] template is nested
|
24
|
+
# @option p_config [String, Symbol] :type
|
25
|
+
# @option p_config [String, Symbol] :default
|
26
|
+
# @option p_config [String, Symbol] :description
|
27
|
+
# @option p_config [String, Symbol] :multiple
|
28
|
+
# @return [Object]
|
29
|
+
def request_compile_parameter(p_name, p_config, cur_val, nested=false)
|
30
|
+
result = nil
|
31
|
+
attempts = 0
|
32
|
+
unless(cur_val || p_config[:default].nil?)
|
33
|
+
cur_val = p_config[:default]
|
34
|
+
end
|
35
|
+
if(cur_val.is_a?(Array))
|
36
|
+
cur_val = cur_val.map(&:to_s).join(',')
|
37
|
+
end
|
38
|
+
until(result && (!result.respond_to?(:empty?) || !result.empty?))
|
39
|
+
attempts += 1
|
40
|
+
if(config[:interactive_parameters] && (!nested || !p_config.key?(:prompt_when_nested) || p_config[:prompt_when_nested] == true))
|
41
|
+
result = ui.ask_question(
|
42
|
+
p_name.to_s.split('_').map(&:capitalize).join,
|
43
|
+
:default => cur_val.to_s.empty? ? nil : cur_val.to_s
|
44
|
+
)
|
45
|
+
else
|
46
|
+
result = cur_val.to_s
|
47
|
+
end
|
48
|
+
case p_config.fetch(:type, 'string').to_s.downcase.to_sym
|
49
|
+
when :string
|
50
|
+
if(p_config[:multiple])
|
51
|
+
result = result.split(',').map(&:strip)
|
52
|
+
end
|
53
|
+
when :number
|
54
|
+
if(p_config[:multiple])
|
55
|
+
result = result.split(',').map(&:strip)
|
56
|
+
new_result = result.map do |item|
|
57
|
+
new_item = item.to_i
|
58
|
+
new_item if new_item.to_s == item
|
59
|
+
end
|
60
|
+
result = new_result.size == result.size ? new_result : []
|
61
|
+
else
|
62
|
+
new_result = result.to_i
|
63
|
+
result = new_result.to_s == result ? new_result : nil
|
64
|
+
end
|
65
|
+
else
|
66
|
+
raise ArgumentError.new "Unknown compile time parameter type provided: `#{p_config[:type].inspect}` (Parameter: #{p_name})"
|
67
|
+
end
|
68
|
+
if(result.nil? || (result.respond_to?(:empty?) && result.empty?))
|
69
|
+
if(attempts > MAX_PARAMETER_ATTEMPTS)
|
70
|
+
ui.fatal 'Failed to receive allowed parameter!'
|
71
|
+
exit 1
|
72
|
+
else
|
73
|
+
ui.error "Invalid value provided for parameter. Must be type: `#{p_config[:type].to_s.capitalize}`"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
result
|
78
|
+
end
|
79
|
+
|
16
80
|
# Load the template file
|
17
81
|
#
|
18
82
|
# @param args [Symbol] options (:allow_missing)
|
@@ -31,18 +95,41 @@ module Sfn
|
|
31
95
|
config[:template]
|
32
96
|
elsif(config[:file])
|
33
97
|
if(config[:processing])
|
98
|
+
compile_state = config.fetch(:compile_parameters, Smash.new)
|
34
99
|
sf = SparkleFormation.compile(config[:file], :sparkle)
|
100
|
+
if(name_args.first)
|
101
|
+
sf.name = name_args.first
|
102
|
+
end
|
103
|
+
sf.compile_time_parameter_setter do |formation|
|
104
|
+
f_name = []
|
105
|
+
f_form = formation
|
106
|
+
while(f_form)
|
107
|
+
f_name.push f_form.name
|
108
|
+
f_form = f_form.parent
|
109
|
+
end
|
110
|
+
f_name = f_name.reverse.map(&:to_s).join('_')
|
111
|
+
current_state = compile_state.fetch(f_name, Smash.new)
|
112
|
+
if(formation.compile_state)
|
113
|
+
current_state = current_state.merge(formation.compile_state)
|
114
|
+
end
|
115
|
+
ui.info "#{ui.color('Compile time parameters:', :bold)} - template: #{ui.color(formation.name, :green, :bold)}"
|
116
|
+
formation.parameters.each do |k,v|
|
117
|
+
current_state[k] = request_compile_parameter(k, v, current_state[k], !!formation.parent)
|
118
|
+
end
|
119
|
+
formation.compile_state = current_state
|
120
|
+
end
|
35
121
|
if(sf.nested? && !sf.isolated_nests?)
|
36
122
|
raise TypeError.new('Template does not contain isolated stack nesting! Cannot process in existing state.')
|
37
123
|
end
|
38
124
|
if(sf.nested? && config[:apply_nesting])
|
39
125
|
sf.apply_nesting do |stack_name, stack_definition|
|
40
|
-
bucket = provider.connection.api_for(:storage).buckets.get(
|
41
|
-
config[:nesting_bucket]
|
42
|
-
)
|
43
126
|
if(config[:print_only])
|
44
|
-
"http://example.com/bucket/#{name_args.first}_#{stack_name}.json"
|
127
|
+
# "http://example.com/bucket/#{name_args.first}_#{stack_name}.json"
|
128
|
+
stack_definition
|
45
129
|
else
|
130
|
+
bucket = provider.connection.api_for(:storage).buckets.get(
|
131
|
+
config[:nesting_bucket]
|
132
|
+
)
|
46
133
|
unless(bucket)
|
47
134
|
raise "Failed to locate configured bucket for stack template storage (#{bucket})!"
|
48
135
|
end
|
data/lib/sfn/version.rb
CHANGED
data/sfn.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.add_dependency 'miasma', '~> 0.2.20'
|
15
15
|
s.add_dependency 'miasma-aws', '~> 0.1.16'
|
16
16
|
s.add_dependency 'net-ssh'
|
17
|
-
s.add_dependency 'sparkle_formation', '>= 0.
|
17
|
+
s.add_dependency 'sparkle_formation', '>= 0.4.0', '< 1.0'
|
18
18
|
s.executables << 'sfn'
|
19
19
|
s.files = Dir['{lib,bin}/**/*'] + %w(sfn.gemspec README.md CHANGELOG.md LICENSE)
|
20
20
|
s.post_install_message = <<-EOF
|
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: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.4.0
|
76
76
|
- - "<"
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '1.0'
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.
|
85
|
+
version: 0.4.0
|
86
86
|
- - "<"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '1.0'
|
@@ -174,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.4.8
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: SparkleFormation CLI
|
181
181
|
test_files: []
|
182
|
-
has_rdoc:
|