convection 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +148 -29
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/bin/convection +7 -1
- data/lib/convection/control/cloud.rb +2 -2
- data/lib/convection/control/stack.rb +6 -9
- data/lib/convection/model/template.rb +11 -6
- data/lib/convection/model/template/condition.rb +2 -7
- data/lib/convection/model/template/resource.rb +3 -3
- 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: 3a392fc50dc24347f0d9d1d2c053c60452012456
|
4
|
+
data.tar.gz: a507193b6289edd3ae3e66d2dc6f4a1e18e567b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1be75c5946facbc993de9e60dbaf156246a5dc6d005ccadab022ab394216224355750c0005124e2fbd031aca40278d83c6d171c3a2ec19b5e9735537a1c832
|
7
|
+
data.tar.gz: 5ef6b2ca93239b47cc53b0ae802f3dcc6fdd942097cc842d840156a8298d8fdecab76f67146827c219dbc587e046fdd9a9aad23c178d6fe36363ae6db1c82863
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,47 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2017-11-20 16:26:30 +0000 using RuboCop version 0.49.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/Gemfile, **/gems.rb
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Exclude:
|
15
|
+
- 'Gemfile'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/EmptyLineAfterMagicComment:
|
20
|
+
Exclude:
|
21
|
+
- 'convection.gemspec'
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
26
|
+
Exclude:
|
27
|
+
- 'lib/convection/control/stack.rb'
|
28
|
+
|
29
|
+
# Offense count: 1
|
30
|
+
# Cop supports --auto-correct.
|
31
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
32
|
+
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
|
33
|
+
Layout/FirstParameterIndentation:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/convection/model/mixin/taggable.rb'
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Cop supports --auto-correct.
|
39
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
40
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
41
|
+
Layout/IndentHeredoc:
|
42
|
+
Exclude:
|
43
|
+
- 'yard_extensions/properties_handler.rb'
|
44
|
+
|
9
45
|
# Offense count: 1
|
10
46
|
Lint/HandleExceptions:
|
11
47
|
Exclude:
|
@@ -16,37 +52,38 @@ Lint/UselessAssignment:
|
|
16
52
|
Exclude:
|
17
53
|
- 'lib/convection/model/template.rb'
|
18
54
|
|
19
|
-
# Offense count:
|
55
|
+
# Offense count: 29
|
20
56
|
Metrics/AbcSize:
|
21
|
-
Max:
|
57
|
+
Max: 63
|
22
58
|
|
23
|
-
# Offense count:
|
59
|
+
# Offense count: 34
|
60
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
61
|
+
Metrics/BlockLength:
|
62
|
+
Max: 140
|
63
|
+
|
64
|
+
# Offense count: 5
|
24
65
|
# Configuration parameters: CountComments.
|
25
66
|
Metrics/ClassLength:
|
26
|
-
|
27
|
-
- 'lib/convection/control/stack.rb'
|
28
|
-
Max: 304
|
67
|
+
Max: 372
|
29
68
|
|
30
|
-
# Offense count:
|
69
|
+
# Offense count: 14
|
31
70
|
Metrics/CyclomaticComplexity:
|
32
|
-
Max:
|
71
|
+
Max: 19
|
33
72
|
|
34
|
-
# Offense count:
|
35
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
73
|
+
# Offense count: 366
|
74
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
36
75
|
# URISchemes: http, https
|
37
76
|
Metrics/LineLength:
|
38
|
-
Max:
|
77
|
+
Max: 236
|
39
78
|
|
40
|
-
# Offense count:
|
79
|
+
# Offense count: 36
|
41
80
|
# Configuration parameters: CountComments.
|
42
81
|
Metrics/MethodLength:
|
43
|
-
|
44
|
-
- 'lib/convection/control/stack.rb'
|
45
|
-
Max: 37
|
82
|
+
Max: 41
|
46
83
|
|
47
|
-
# Offense count:
|
84
|
+
# Offense count: 12
|
48
85
|
Metrics/PerceivedComplexity:
|
49
|
-
Max:
|
86
|
+
Max: 20
|
50
87
|
|
51
88
|
# Offense count: 2
|
52
89
|
Style/AccessorMethodName:
|
@@ -64,31 +101,113 @@ Style/Alias:
|
|
64
101
|
- 'lib/convection/model/template/resource_property.rb'
|
65
102
|
- 'lib/convection/model/template/resource_property/aws_ec2_network_interface.rb'
|
66
103
|
|
67
|
-
# Offense count:
|
104
|
+
# Offense count: 41
|
68
105
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
69
106
|
# SupportedStyles: nested, compact
|
70
107
|
Style/ClassAndModuleChildren:
|
71
|
-
|
72
|
-
- 'lib/convection/model/template.rb'
|
73
|
-
- 'spec/**/*'
|
108
|
+
Enabled: false
|
74
109
|
|
75
110
|
# Offense count: 4
|
76
111
|
Style/Documentation:
|
77
112
|
Exclude:
|
78
113
|
- 'spec/**/*'
|
114
|
+
- 'test/**/*'
|
79
115
|
- 'lib/convection/model/attributes.rb'
|
80
116
|
- 'lib/convection/model/mixin/colorize.rb'
|
81
117
|
- 'lib/convection/model/template/condition.rb'
|
82
118
|
|
83
119
|
# Offense count: 1
|
84
120
|
# Cop supports --auto-correct.
|
85
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles
|
86
|
-
# SupportedStyles:
|
87
|
-
Style/
|
121
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
122
|
+
# SupportedStyles: compact, expanded
|
123
|
+
Style/EmptyMethod:
|
88
124
|
Exclude:
|
89
|
-
- 'lib/convection/model/
|
125
|
+
- 'lib/convection/model/template/resource_collection.rb'
|
90
126
|
|
91
|
-
#
|
92
|
-
|
127
|
+
# Offense count: 233
|
128
|
+
# Cop supports --auto-correct.
|
129
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
130
|
+
# SupportedStyles: when_needed, always, never
|
131
|
+
Style/FrozenStringLiteralComment:
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
# Offense count: 3
|
135
|
+
# Cop supports --auto-correct.
|
136
|
+
Style/MultilineIfModifier:
|
93
137
|
Exclude:
|
94
|
-
- 'lib/convection/
|
138
|
+
- 'lib/convection/control/stack.rb'
|
139
|
+
- 'lib/convection/model/template/resource.rb'
|
140
|
+
- 'spec/convection/model/template/resource_collection_spec.rb'
|
141
|
+
|
142
|
+
# Offense count: 1
|
143
|
+
# Cop supports --auto-correct.
|
144
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
|
145
|
+
# SupportedStyles: predicate, comparison
|
146
|
+
Style/NumericPredicate:
|
147
|
+
Exclude:
|
148
|
+
- 'spec/**/*'
|
149
|
+
- 'lib/convection/control/stack.rb'
|
150
|
+
|
151
|
+
# Offense count: 29
|
152
|
+
# Cop supports --auto-correct.
|
153
|
+
# Configuration parameters: PreferredDelimiters.
|
154
|
+
Style/PercentLiteralDelimiters:
|
155
|
+
Exclude:
|
156
|
+
- 'bin/convection'
|
157
|
+
- 'convection.gemspec'
|
158
|
+
- 'lib/convection/control/stack.rb'
|
159
|
+
- 'lib/convection/model/template.rb'
|
160
|
+
- 'lib/convection/model/template/resource_property/aws_cloudfront_cachebehavior.rb'
|
161
|
+
- 'lib/convection/model/template/resource_property/aws_cloudfront_defaultcachebehavior.rb'
|
162
|
+
- 'spec/convection/control/stack_spec.rb'
|
163
|
+
- 'spec/convection/dsl/intrinsic_functions_spec.rb'
|
164
|
+
- 'spec/convection/model/cloudfile_spec.rb'
|
165
|
+
- 'spec/convection/model/template/resource/events_rule_spec.rb'
|
166
|
+
- 'spec/convection/model/template/resource/lambdas_spec.rb'
|
167
|
+
- 'spec/convection/model/template/resource/permission_spec.rb'
|
168
|
+
- 'spec/convection/model/template/resource/vpc_endpoints_spec.rb'
|
169
|
+
- 'spec/ec2_client_context.rb'
|
170
|
+
|
171
|
+
# Offense count: 2
|
172
|
+
# Cop supports --auto-correct.
|
173
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
174
|
+
# SupportedStyles: slashes, percent_r, mixed
|
175
|
+
Style/RegexpLiteral:
|
176
|
+
Exclude:
|
177
|
+
- 'convection.gemspec'
|
178
|
+
|
179
|
+
# Offense count: 17
|
180
|
+
# Cop supports --auto-correct.
|
181
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
|
182
|
+
Style/SafeNavigation:
|
183
|
+
Exclude:
|
184
|
+
- 'lib/convection/control/cloud.rb'
|
185
|
+
- 'lib/convection/control/stack.rb'
|
186
|
+
|
187
|
+
# Offense count: 6
|
188
|
+
# Cop supports --auto-correct.
|
189
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
190
|
+
# SupportedStyles: percent, brackets
|
191
|
+
Style/SymbolArray:
|
192
|
+
EnforcedStyle: brackets
|
193
|
+
|
194
|
+
# Offense count: 1
|
195
|
+
# Cop supports --auto-correct.
|
196
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
|
197
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
198
|
+
Style/TernaryParentheses:
|
199
|
+
Exclude:
|
200
|
+
- 'lib/convection/dsl/helpers.rb'
|
201
|
+
|
202
|
+
# Offense count: 2
|
203
|
+
# Cop supports --auto-correct.
|
204
|
+
Style/UnneededPercentQ:
|
205
|
+
Exclude:
|
206
|
+
- 'convection.gemspec'
|
207
|
+
|
208
|
+
# Offense count: 4
|
209
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
210
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
211
|
+
Style/VariableNumber:
|
212
|
+
Exclude:
|
213
|
+
- 'lib/convection/dsl/intrinsic_functions.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.3.5
|
data/Gemfile
CHANGED
data/bin/convection
CHANGED
@@ -23,6 +23,7 @@ module Convection
|
|
23
23
|
option :'very-verbose', :type => :boolean, :aliases => '--vv', :desc => 'Show unchanged stacks', default: true
|
24
24
|
option :cloudfiles, :type => :array, :default => %w(Cloudfile)
|
25
25
|
option :delayed_output, :type => :boolean, :desc => 'Delay output until operation completion.', :default => false
|
26
|
+
option :retain, :type => :boolean, :desc => 'Retain stack resources, without deleteing.', :default => false
|
26
27
|
def converge(stack = nil)
|
27
28
|
@outputs = []
|
28
29
|
operation('converge', stack)
|
@@ -62,6 +63,7 @@ module Convection
|
|
62
63
|
option :'very-verbose', :type => :boolean, :aliases => '--vv', :desc => 'Show unchanged stacks'
|
63
64
|
option :cloudfiles, :type => :array, :default => %w(Cloudfile)
|
64
65
|
option :delayed_output, :type => :boolean, :desc => 'Delay output until operation completion.', :default => false
|
66
|
+
option :retain, :type => :boolean, :desc => 'Retain stack resources, without deleteing.', :default => false
|
65
67
|
def diff(stack = nil)
|
66
68
|
@outputs = []
|
67
69
|
operation('diff', stack)
|
@@ -133,7 +135,11 @@ module Convection
|
|
133
135
|
cloud_array[:cloud].configure(File.absolute_path(cloud_array[:cloudfile_path], @cwd))
|
134
136
|
cloud = cloud_array[:cloud]
|
135
137
|
region = cloud.cloudfile.region
|
136
|
-
|
138
|
+
operation_kwargs = {
|
139
|
+
stack_group: options[:stack_group], stacks: options[:stacks],
|
140
|
+
exclude_stacks: options[:exclude_stacks], retain: options[:retain]
|
141
|
+
}
|
142
|
+
cloud.send(task_name, stack, operation_kwargs) do |event, errors|
|
137
143
|
if options[:cloudfiles].length > 1 && options[:delayed_output]
|
138
144
|
output << { event: event, errors: errors }
|
139
145
|
else
|
@@ -91,7 +91,7 @@ module Convection
|
|
91
91
|
|
92
92
|
filter_deck(options, &block).each_value do |stack|
|
93
93
|
block.call(Model::Event.new(:converge, "Stack #{ stack.name }", :info)) if block
|
94
|
-
stack.apply(&block)
|
94
|
+
stack.apply(retain: options[:retain], &block)
|
95
95
|
|
96
96
|
emit_credential_error_and_exit!(stack, &block) if stack.credential_error?
|
97
97
|
if stack.error?
|
@@ -142,7 +142,7 @@ module Convection
|
|
142
142
|
filter_deck(options, &block).each_value do |stack|
|
143
143
|
block.call(Model::Event.new(:compare, "Compare local state of stack #{ stack.name } (#{ stack.cloud_name }) with remote template", :info))
|
144
144
|
|
145
|
-
difference = stack.diff
|
145
|
+
difference = stack.diff(retain: options[:retain])
|
146
146
|
# Find errors during diff
|
147
147
|
emit_credential_error_and_exit!(stack, &block) if stack.credential_error?
|
148
148
|
if stack.error?
|
@@ -87,7 +87,6 @@ module Convection
|
|
87
87
|
# Represents a stack task that is currently in progress.
|
88
88
|
TASK_IN_PROGRESS = 'TASK_IN_PROGRESS'.freeze
|
89
89
|
|
90
|
-
# rubocop:disable Metrics/LineLength
|
91
90
|
# @param name [String] the name of the CloudFormation Stack
|
92
91
|
# @param template [Convection::Model::Template] a wrapper of the
|
93
92
|
# CloudFormation template (can be rendered into CF JSON)
|
@@ -148,7 +147,6 @@ module Convection
|
|
148
147
|
# clouds use this, for example, to create security groups early
|
149
148
|
# in the dependency tree to avoid the chicken-and-egg problem.
|
150
149
|
@template.execute
|
151
|
-
|
152
150
|
rescue Aws::Errors::ServiceError => e
|
153
151
|
@errors << e
|
154
152
|
end
|
@@ -167,7 +165,6 @@ module Convection
|
|
167
165
|
rescue Aws::Errors::ServiceError => e
|
168
166
|
@errors << e
|
169
167
|
end
|
170
|
-
# rubocop:enable Metrics/LineLength
|
171
168
|
|
172
169
|
def cloud_name
|
173
170
|
return @cloud_name unless @cloud_name.nil?
|
@@ -281,8 +278,8 @@ module Convection
|
|
281
278
|
# template (in CloudFormation) and the state of the rendered
|
282
279
|
# template (what *would* be converged).
|
283
280
|
# @see Convection::Model::Template#diff
|
284
|
-
def diff
|
285
|
-
@template.diff(@current_template)
|
281
|
+
def diff(retain: false)
|
282
|
+
@template.diff(@current_template, retain: retain)
|
286
283
|
end
|
287
284
|
|
288
285
|
# @return [Boolean] whether the Resources section of the rendered
|
@@ -324,9 +321,9 @@ module Convection
|
|
324
321
|
#
|
325
322
|
# @param block [Proc] a configuration block to pass any
|
326
323
|
# {Convection::Model::Event}s to.
|
327
|
-
def apply(&block)
|
324
|
+
def apply(retain: false, &block)
|
328
325
|
request_options = @options.clone.tap do |o|
|
329
|
-
o[:template_body] = to_json
|
326
|
+
o[:template_body] = to_json(retain: retain)
|
330
327
|
o[:parameters] = cf_parameters
|
331
328
|
o[:capabilities] = capabilities
|
332
329
|
end
|
@@ -334,7 +331,7 @@ module Convection
|
|
334
331
|
# Get the state of existence before creation
|
335
332
|
existing_stack = exist?
|
336
333
|
if existing_stack
|
337
|
-
if diff.empty? ## No Changes. Just get resources and move on
|
334
|
+
if diff(retain: retain).empty? ## No Changes. Just get resources and move on
|
338
335
|
block.call(Model::Event.new(:complete, "Stack #{ name } has no changes", :info)) if block
|
339
336
|
get_status
|
340
337
|
return
|
@@ -554,7 +551,7 @@ module Convection
|
|
554
551
|
collection << event
|
555
552
|
end
|
556
553
|
|
557
|
-
break if pages
|
554
|
+
break if pages.zero?
|
558
555
|
end
|
559
556
|
|
560
557
|
@last_event_seen = collection.first.event_id unless collection.empty?
|
@@ -251,7 +251,7 @@ module Convection
|
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
-
def render(stack_ = nil)
|
254
|
+
def render(stack_ = nil, retain: false)
|
255
255
|
## Instantiate a new template with the definition block and an other stack
|
256
256
|
return clone(stack_).render unless stack_.nil?
|
257
257
|
|
@@ -263,7 +263,12 @@ module Convection
|
|
263
263
|
'Parameters' => parameters.map(&:render),
|
264
264
|
'Mappings' => mappings.map(&:render),
|
265
265
|
'Conditions' => conditions.map(&:render),
|
266
|
-
'Resources' => all_resources.map
|
266
|
+
'Resources' => all_resources.map do |resource|
|
267
|
+
if retain && resource.deletion_policy.nil?
|
268
|
+
resource.deletion_policy('Retain')
|
269
|
+
end
|
270
|
+
resource.render
|
271
|
+
end,
|
267
272
|
'Outputs' => outputs.map(&:render),
|
268
273
|
'Metadata' => metadata.map(&:render)
|
269
274
|
}
|
@@ -275,12 +280,12 @@ module Convection
|
|
275
280
|
end
|
276
281
|
end
|
277
282
|
|
278
|
-
def diff(other, stack_ = nil)
|
279
|
-
render(stack_).diff(other).map { |diff| Diff.new(diff[0], *diff[1]) }
|
283
|
+
def diff(other, stack_ = nil, retain: false)
|
284
|
+
render(stack_, retain: retain).diff(other).map { |diff| Diff.new(diff[0], *diff[1]) }
|
280
285
|
end
|
281
286
|
|
282
|
-
def to_json(stack_ = nil, pretty = false)
|
283
|
-
rendered_stack = render(stack_)
|
287
|
+
def to_json(stack_ = nil, pretty = false, retain: false)
|
288
|
+
rendered_stack = render(stack_, retain: retain)
|
284
289
|
validate(rendered_stack)
|
285
290
|
return JSON.generate(rendered_stack) unless pretty
|
286
291
|
JSON.pretty_generate(rendered_stack)
|
@@ -38,13 +38,8 @@ module Convection
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def render
|
41
|
-
rendered_values =
|
42
|
-
|
43
|
-
if function_arg.respond_to? :render # the argument is another conditional function
|
44
|
-
rendered_values << function_arg.render
|
45
|
-
else
|
46
|
-
rendered_values << function_arg
|
47
|
-
end
|
41
|
+
rendered_values = Array(@function_arguments).map do |function_arg|
|
42
|
+
function_arg.respond_to?(:render) ? function_arg.render : function_arg
|
48
43
|
end
|
49
44
|
|
50
45
|
{ CONDITIONAL_FUNCTION_SYNTAX_MAP[@function_name] => rendered_values }
|
@@ -323,13 +323,13 @@ module Convection
|
|
323
323
|
@depends_on << (resource.is_a?(Resource) ? resource.name : resource)
|
324
324
|
end
|
325
325
|
|
326
|
-
# rubocop:disable Style/TrivialAccessors
|
327
326
|
# We don't want to use an accessor (e.g. deletion_policy=) because
|
328
327
|
# this is a DSL method
|
329
|
-
def deletion_policy(deletion_policy)
|
328
|
+
def deletion_policy(deletion_policy = :unset_deletion_policy)
|
329
|
+
return @deletion_policy if deletion_policy == :unset_deletion_policy
|
330
|
+
|
330
331
|
@deletion_policy = deletion_policy
|
331
332
|
end
|
332
|
-
# rubocop:enable Style/TrivialAccessors
|
333
333
|
|
334
334
|
def reference
|
335
335
|
{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|