sfn 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/bin/command-config-generator +44 -0
- data/bin/sfn +1 -5
- data/docs/README.md +2 -1
- data/docs/callbacks.md +18 -0
- data/docs/command-config.md +1276 -0
- data/docs/configuration.md +0 -105
- data/docs/overview.md +1 -0
- data/lib/sfn.rb +1 -0
- data/lib/sfn/api_provider.rb +9 -0
- data/lib/sfn/api_provider/google.rb +84 -0
- data/lib/sfn/command.rb +22 -0
- data/lib/sfn/command/create.rb +33 -45
- data/lib/sfn/command/describe.rb +1 -1
- data/lib/sfn/command/destroy.rb +7 -1
- data/lib/sfn/command/diff.rb +4 -5
- data/lib/sfn/command/graph.rb +1 -3
- data/lib/sfn/command/print.rb +3 -4
- data/lib/sfn/command/update.rb +89 -87
- data/lib/sfn/command/validate.rb +24 -11
- data/lib/sfn/command_module/base.rb +1 -12
- data/lib/sfn/command_module/stack.rb +45 -56
- data/lib/sfn/command_module/template.rb +74 -33
- data/lib/sfn/config/print.rb +5 -0
- data/lib/sfn/config/update.rb +4 -0
- data/lib/sfn/config/validate.rb +4 -0
- data/lib/sfn/monkey_patch/stack.rb +153 -83
- data/lib/sfn/monkey_patch/stack/azure.rb +23 -0
- data/lib/sfn/monkey_patch/stack/google.rb +129 -0
- data/lib/sfn/planner/aws.rb +111 -72
- data/lib/sfn/utils/json.rb +3 -0
- data/lib/sfn/utils/stack_parameter_scrubber.rb +20 -23
- data/lib/sfn/utils/stack_parameter_validator.rb +162 -157
- data/lib/sfn/version.rb +1 -1
- data/sfn.gemspec +3 -2
- metadata +34 -8
@@ -4,183 +4,188 @@ module Sfn
|
|
4
4
|
module Utils
|
5
5
|
|
6
6
|
# Helper utility for validating stack parameters
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
7
|
+
module StackParameterValidator
|
8
|
+
|
9
|
+
include Bogo::AnimalStrings
|
10
|
+
|
11
|
+
# HOT parameter mapping
|
12
|
+
HEAT_CONSTRAINT_MAP = {
|
13
|
+
'MaxLength' => [:length, :max],
|
14
|
+
'MinLength' => [:length, :min],
|
15
|
+
'MaxValue' => [:range, :max],
|
16
|
+
'MinValue' => [:range, :min],
|
17
|
+
'AllowedValues' => [:allowed_values],
|
18
|
+
'AllowedPattern' => [:allowed_pattern]
|
19
|
+
}
|
20
|
+
|
21
|
+
# GCDM parameter mapping
|
22
|
+
GOOGLE_CONSTRAINT_MAP = {
|
23
|
+
'AllowedPattern' => [:pattern],
|
24
|
+
'MaxValue' => [:maximum],
|
25
|
+
'MinValue' => [:minimum]
|
26
|
+
}
|
27
|
+
|
28
|
+
# Parameter mapping identifier and content
|
29
|
+
PARAMETER_DEFINITION_MAP = {
|
30
|
+
'constraints' => HEAT_CONSTRAINT_MAP
|
31
|
+
}
|
32
|
+
|
33
|
+
# Supported parameter validations
|
34
|
+
PARAMETER_VALIDATIONS = [
|
35
|
+
'allowed_values',
|
36
|
+
'allowed_pattern',
|
37
|
+
'max_length',
|
38
|
+
'min_length',
|
39
|
+
'max_value',
|
40
|
+
'min_value'
|
41
|
+
]
|
42
|
+
|
43
|
+
# Validate a parameters
|
44
|
+
#
|
45
|
+
# @param value [Object] value for parameter
|
46
|
+
# @param parameter_definition [Hash]
|
47
|
+
# @option parameter_definition [Array<String>] 'AllowedValues'
|
48
|
+
# @option parameter_definition [String] 'AllowedPattern'
|
49
|
+
# @option parameter_definition [String, Integer] 'MaxLength'
|
50
|
+
# @option parameter_definition [String, Integer] 'MinLength'
|
51
|
+
# @option parameter_definition [String, Integer] 'MaxValue'
|
52
|
+
# @option parameter_definition [String, Integer] 'MinValue'
|
53
|
+
# @return [TrueClass, Array<String>] true if valid. array of string errors if invalid
|
54
|
+
def validate_parameter(value, parameter_definition)
|
55
|
+
return [[:blank, 'Value cannot be blank']] if value.to_s.strip.empty?
|
56
|
+
parameter_definition = reformat_definition(parameter_definition)
|
57
|
+
value_list = list_type?(parameter_definition.fetch('Type', parameter_definition['type'].to_s)) ? value.to_s.split(',') : [value]
|
58
|
+
result = PARAMETER_VALIDATIONS.map do |validator_key|
|
59
|
+
valid_key = parameter_definition.keys.detect do |pdef_key|
|
60
|
+
pdef_key.downcase.gsub('_', '') == validator_key.downcase.gsub('_', '')
|
61
|
+
end
|
62
|
+
if(valid_key)
|
63
|
+
value_list.map do |value|
|
64
|
+
res = self.send(validator_key, value, parameter_definition[valid_key])
|
65
|
+
res == true ? true : [validator_key, res]
|
63
66
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
67
|
+
else
|
68
|
+
true
|
69
|
+
end
|
70
|
+
end.flatten(1)
|
71
|
+
result.delete_if{|x| x == true}
|
72
|
+
result.empty? ? true : result
|
73
|
+
end
|
68
74
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
75
|
+
# Reformat parameter definition with proper keys to allow
|
76
|
+
# validation for templates different parameter definition
|
77
|
+
# layout
|
78
|
+
#
|
79
|
+
# @param pdef [Hash]
|
80
|
+
# @return [Hash]
|
81
|
+
def reformat_definition(pdef)
|
82
|
+
new_def = pdef
|
83
|
+
PARAMETER_DEFINITION_MAP.each do |ident, mapping|
|
84
|
+
if(pdef[ident])
|
85
|
+
new_def = Smash.new
|
86
|
+
mapping.each do |new_key, current_path|
|
87
|
+
if(pdef.get(*current_path))
|
88
|
+
new_def[new_key] = pdef.get(*current_path)
|
84
89
|
end
|
85
90
|
end
|
86
91
|
end
|
87
|
-
new_def
|
88
|
-
end
|
89
|
-
|
90
|
-
# Parameter is within allowed values
|
91
|
-
#
|
92
|
-
# @param value [String]
|
93
|
-
# @param pdef [Hash] parameter definition
|
94
|
-
# @option pdef [Array<String>] 'AllowedValues'
|
95
|
-
# @return [TrueClass, String]
|
96
|
-
def allowed_values(value, pdef)
|
97
|
-
if(pdef.include?(value))
|
98
|
-
true
|
99
|
-
else
|
100
|
-
"Not an allowed value: #{pdef.join(', ')}"
|
101
|
-
end
|
102
92
|
end
|
93
|
+
new_def
|
94
|
+
end
|
103
95
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
96
|
+
# Parameter is within allowed values
|
97
|
+
#
|
98
|
+
# @param value [String]
|
99
|
+
# @param pdef [Hash] parameter definition
|
100
|
+
# @option pdef [Array<String>] 'AllowedValues'
|
101
|
+
# @return [TrueClass, String]
|
102
|
+
def allowed_values(value, pdef)
|
103
|
+
if(pdef.include?(value))
|
104
|
+
true
|
105
|
+
else
|
106
|
+
"Not an allowed value: #{pdef.join(', ')}"
|
116
107
|
end
|
108
|
+
end
|
117
109
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
110
|
+
# Parameter matches allowed pattern
|
111
|
+
#
|
112
|
+
# @param value [String]
|
113
|
+
# @param pdef [Hash] parameter definition
|
114
|
+
# @option pdef [String] 'AllowedPattern'
|
115
|
+
# @return [TrueClass, String]
|
116
|
+
def allowed_pattern(value, pdef)
|
117
|
+
if(value.match(%r{#{pdef}}))
|
118
|
+
true
|
119
|
+
else
|
120
|
+
"Not a valid pattern. Must match: #{pdef}"
|
130
121
|
end
|
122
|
+
end
|
131
123
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
124
|
+
# Parameter length is less than or equal to max length
|
125
|
+
#
|
126
|
+
# @param value [String, Integer]
|
127
|
+
# @param pdef [Hash] parameter definition
|
128
|
+
# @option pdef [String] 'MaxLength'
|
129
|
+
# @return [TrueClass, String]
|
130
|
+
def max_length(value, pdef)
|
131
|
+
if(value.length <= pdef.to_i)
|
132
|
+
true
|
133
|
+
else
|
134
|
+
"Value must not exceed #{pdef} characters"
|
144
135
|
end
|
136
|
+
end
|
145
137
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
138
|
+
# Parameter length is greater than or equal to min length
|
139
|
+
#
|
140
|
+
# @param value [String]
|
141
|
+
# @param pdef [Hash] parameter definition
|
142
|
+
# @option pdef [String] 'MinLength'
|
143
|
+
# @return [TrueClass, String]
|
144
|
+
def min_length(value, pdef)
|
145
|
+
if(value.length >= pdef.to_i)
|
146
|
+
true
|
147
|
+
else
|
148
|
+
"Value must be at least #{pdef} characters"
|
158
149
|
end
|
150
|
+
end
|
159
151
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
end
|
152
|
+
# Parameter value is less than or equal to max value
|
153
|
+
#
|
154
|
+
# @param value [String]
|
155
|
+
# @param pdef [Hash] parameter definition
|
156
|
+
# @option pdef [String] 'MaxValue'
|
157
|
+
# @return [TrueClass, String]
|
158
|
+
def max_value(value, pdef)
|
159
|
+
if(value.to_i <= pdef.to_i)
|
160
|
+
true
|
161
|
+
else
|
162
|
+
"Value must not be greater than #{pdef}"
|
172
163
|
end
|
164
|
+
end
|
173
165
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
166
|
+
# Parameter value is greater than or equal to min value
|
167
|
+
#
|
168
|
+
# @param value [String]
|
169
|
+
# @param pdef [Hash] parameter definition
|
170
|
+
# @option pdef [String] 'MinValue'
|
171
|
+
# @return [TrueClass, String]
|
172
|
+
def min_value(value, pdef)
|
173
|
+
if(value.to_i >= pdef.to_i)
|
174
|
+
true
|
175
|
+
else
|
176
|
+
"Value must not be less than #{pdef}"
|
181
177
|
end
|
178
|
+
end
|
182
179
|
|
180
|
+
# Check if type is a list type
|
181
|
+
#
|
182
|
+
# @param type [String]
|
183
|
+
# @return [TrueClass, FalseClass]
|
184
|
+
def list_type?(type)
|
185
|
+
type = type.downcase
|
186
|
+
type.start_with?('comma') || type.start_with?('list<')
|
183
187
|
end
|
188
|
+
|
184
189
|
end
|
185
190
|
end
|
186
191
|
end
|
data/lib/sfn/version.rb
CHANGED
data/sfn.gemspec
CHANGED
@@ -13,12 +13,13 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.add_runtime_dependency 'bogo-cli', '>= 0.2.5', '< 0.4'
|
14
14
|
s.add_runtime_dependency 'bogo-ui', '>= 0.1.13', '< 0.4'
|
15
15
|
s.add_runtime_dependency 'miasma', '>= 0.3.0', '< 0.4'
|
16
|
-
s.add_runtime_dependency 'miasma-aws', '>= 0.3.
|
16
|
+
s.add_runtime_dependency 'miasma-aws', '>= 0.3.3', '< 0.4'
|
17
17
|
s.add_runtime_dependency 'miasma-azure', '>= 0.1.0', '< 0.3'
|
18
18
|
s.add_runtime_dependency 'miasma-open-stack', '>= 0.1.0', '< 0.3'
|
19
19
|
s.add_runtime_dependency 'miasma-rackspace', '>= 0.1.0', '< 0.3'
|
20
|
+
s.add_runtime_dependency 'miasma-google', '>= 0.1.0', '< 0.3'
|
20
21
|
s.add_runtime_dependency 'net-ssh'
|
21
|
-
s.add_runtime_dependency 'sparkle_formation', '>=
|
22
|
+
s.add_runtime_dependency 'sparkle_formation', '>= 3', '< 4'
|
22
23
|
s.add_runtime_dependency 'hashdiff', '~> 0.2.2'
|
23
24
|
s.add_runtime_dependency 'graph', '~> 2.8.1'
|
24
25
|
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:
|
4
|
+
version: 3.0.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: 2016-04-
|
11
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo-cli
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.3.
|
79
|
+
version: 0.3.3
|
80
80
|
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.4'
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.3.
|
89
|
+
version: 0.3.3
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0.4'
|
@@ -150,6 +150,26 @@ dependencies:
|
|
150
150
|
- - "<"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.3'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: miasma-google
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.0
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0.3'
|
163
|
+
type: :runtime
|
164
|
+
prerelease: false
|
165
|
+
version_requirements: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 0.1.0
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.3'
|
153
173
|
- !ruby/object:Gem::Dependency
|
154
174
|
name: net-ssh
|
155
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,20 +190,20 @@ dependencies:
|
|
170
190
|
requirements:
|
171
191
|
- - ">="
|
172
192
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
193
|
+
version: '3'
|
174
194
|
- - "<"
|
175
195
|
- !ruby/object:Gem::Version
|
176
|
-
version: '
|
196
|
+
version: '4'
|
177
197
|
type: :runtime
|
178
198
|
prerelease: false
|
179
199
|
version_requirements: !ruby/object:Gem::Requirement
|
180
200
|
requirements:
|
181
201
|
- - ">="
|
182
202
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
203
|
+
version: '3'
|
184
204
|
- - "<"
|
185
205
|
- !ruby/object:Gem::Version
|
186
|
-
version: '
|
206
|
+
version: '4'
|
187
207
|
- !ruby/object:Gem::Dependency
|
188
208
|
name: hashdiff
|
189
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,10 +284,12 @@ files:
|
|
264
284
|
- CHANGELOG.md
|
265
285
|
- LICENSE
|
266
286
|
- README.md
|
287
|
+
- bin/command-config-generator
|
267
288
|
- bin/generate_sfn_docs
|
268
289
|
- bin/sfn
|
269
290
|
- docs/README.md
|
270
291
|
- docs/callbacks.md
|
292
|
+
- docs/command-config.md
|
271
293
|
- docs/commands.md
|
272
294
|
- docs/configuration.md
|
273
295
|
- docs/images/d_create.png
|
@@ -292,6 +314,8 @@ files:
|
|
292
314
|
- docs/v/loader.js
|
293
315
|
- lib/chef/knife/knife_plugin_seed.rb
|
294
316
|
- lib/sfn.rb
|
317
|
+
- lib/sfn/api_provider.rb
|
318
|
+
- lib/sfn/api_provider/google.rb
|
295
319
|
- lib/sfn/cache.rb
|
296
320
|
- lib/sfn/callback.rb
|
297
321
|
- lib/sfn/callback/aws_assume_role.rb
|
@@ -338,6 +362,8 @@ files:
|
|
338
362
|
- lib/sfn/config/validate.rb
|
339
363
|
- lib/sfn/monkey_patch.rb
|
340
364
|
- lib/sfn/monkey_patch/stack.rb
|
365
|
+
- lib/sfn/monkey_patch/stack/azure.rb
|
366
|
+
- lib/sfn/monkey_patch/stack/google.rb
|
341
367
|
- lib/sfn/planner.rb
|
342
368
|
- lib/sfn/planner/aws.rb
|
343
369
|
- lib/sfn/provider.rb
|