sfn 3.0.30 → 3.0.32
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 +6 -0
- data/bin/sfn +16 -14
- data/lib/chef/knife/knife_plugin_seed.rb +12 -12
- data/lib/sfn.rb +17 -17
- data/lib/sfn/api_provider.rb +3 -3
- data/lib/sfn/api_provider/google.rb +2 -2
- data/lib/sfn/api_provider/terraform.rb +2 -2
- data/lib/sfn/cache.rb +9 -9
- data/lib/sfn/callback.rb +6 -6
- data/lib/sfn/callback/aws_assume_role.rb +5 -5
- data/lib/sfn/callback/aws_mfa.rb +8 -6
- data/lib/sfn/callback/stack_policy.rb +15 -15
- data/lib/sfn/command.rb +37 -36
- data/lib/sfn/command/conf.rb +12 -12
- data/lib/sfn/command/create.rb +9 -9
- data/lib/sfn/command/describe.rb +6 -6
- data/lib/sfn/command/destroy.rb +8 -8
- data/lib/sfn/command/diff.rb +31 -31
- data/lib/sfn/command/events.rb +6 -6
- data/lib/sfn/command/export.rb +8 -8
- data/lib/sfn/command/graph.rb +21 -21
- data/lib/sfn/command/graph/aws.rb +34 -34
- data/lib/sfn/command/graph/provider.rb +1 -1
- data/lib/sfn/command/graph/terraform.rb +41 -41
- data/lib/sfn/command/import.rb +17 -17
- data/lib/sfn/command/init.rb +15 -15
- data/lib/sfn/command/inspect.rb +16 -16
- data/lib/sfn/command/lint.rb +6 -6
- data/lib/sfn/command/list.rb +2 -2
- data/lib/sfn/command/plan.rb +227 -0
- data/lib/sfn/command/print.rb +4 -4
- data/lib/sfn/command/promote.rb +2 -2
- data/lib/sfn/command/update.rb +19 -144
- data/lib/sfn/command/validate.rb +17 -13
- data/lib/sfn/command_module.rb +6 -5
- data/lib/sfn/command_module/base.rb +8 -8
- data/lib/sfn/command_module/callbacks.rb +5 -5
- data/lib/sfn/command_module/planning.rb +151 -0
- data/lib/sfn/command_module/stack.rb +34 -34
- data/lib/sfn/command_module/template.rb +50 -50
- data/lib/sfn/config.rb +46 -44
- data/lib/sfn/config/conf.rb +3 -3
- data/lib/sfn/config/create.rb +9 -9
- data/lib/sfn/config/describe.rb +7 -7
- data/lib/sfn/config/destroy.rb +1 -1
- data/lib/sfn/config/diff.rb +3 -3
- data/lib/sfn/config/events.rb +9 -9
- data/lib/sfn/config/export.rb +5 -5
- data/lib/sfn/config/graph.rb +10 -10
- data/lib/sfn/config/import.rb +4 -4
- data/lib/sfn/config/init.rb +1 -1
- data/lib/sfn/config/inspect.rb +16 -16
- data/lib/sfn/config/lint.rb +5 -5
- data/lib/sfn/config/list.rb +6 -6
- data/lib/sfn/config/plan.rb +28 -0
- data/lib/sfn/config/print.rb +5 -5
- data/lib/sfn/config/promote.rb +4 -4
- data/lib/sfn/config/update.rb +18 -18
- data/lib/sfn/config/validate.rb +30 -30
- data/lib/sfn/lint.rb +5 -5
- data/lib/sfn/lint/definition.rb +3 -3
- data/lib/sfn/lint/rule.rb +3 -3
- data/lib/sfn/lint/rule_set.rb +2 -2
- data/lib/sfn/monkey_patch.rb +2 -2
- data/lib/sfn/monkey_patch/stack.rb +27 -27
- data/lib/sfn/monkey_patch/stack/azure.rb +1 -1
- data/lib/sfn/monkey_patch/stack/google.rb +5 -5
- data/lib/sfn/planner.rb +4 -4
- data/lib/sfn/planner/aws.rb +114 -70
- data/lib/sfn/provider.rb +13 -13
- data/lib/sfn/utils.rb +10 -10
- data/lib/sfn/utils/debug.rb +2 -2
- data/lib/sfn/utils/json.rb +1 -1
- data/lib/sfn/utils/object_storage.rb +3 -3
- data/lib/sfn/utils/output.rb +4 -4
- data/lib/sfn/utils/path_selector.rb +15 -15
- data/lib/sfn/utils/ssher.rb +4 -4
- data/lib/sfn/utils/stack_exporter.rb +16 -16
- data/lib/sfn/utils/stack_parameter_scrubber.rb +6 -6
- data/lib/sfn/utils/stack_parameter_validator.rb +22 -22
- data/lib/sfn/version.rb +1 -1
- data/sfn.gemspec +32 -32
- metadata +16 -13
data/lib/sfn/utils.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
# Utility classes and modules
|
|
5
5
|
module Utils
|
|
6
|
-
autoload :Output,
|
|
7
|
-
autoload :StackParameterValidator,
|
|
8
|
-
autoload :StackParameterScrubber,
|
|
9
|
-
autoload :StackExporter,
|
|
10
|
-
autoload :Debug,
|
|
11
|
-
autoload :JSON,
|
|
12
|
-
autoload :Ssher,
|
|
13
|
-
autoload :ObjectStorage,
|
|
14
|
-
autoload :PathSelector,
|
|
6
|
+
autoload :Output, "sfn/utils/output"
|
|
7
|
+
autoload :StackParameterValidator, "sfn/utils/stack_parameter_validator"
|
|
8
|
+
autoload :StackParameterScrubber, "sfn/utils/stack_parameter_scrubber"
|
|
9
|
+
autoload :StackExporter, "sfn/utils/stack_exporter"
|
|
10
|
+
autoload :Debug, "sfn/utils/debug"
|
|
11
|
+
autoload :JSON, "sfn/utils/json"
|
|
12
|
+
autoload :Ssher, "sfn/utils/ssher"
|
|
13
|
+
autoload :ObjectStorage, "sfn/utils/object_storage"
|
|
14
|
+
autoload :PathSelector, "sfn/utils/path_selector"
|
|
15
15
|
|
|
16
16
|
# Provide methods directly from module for previous version compatibility
|
|
17
17
|
extend JSON
|
data/lib/sfn/utils/debug.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -10,7 +10,7 @@ module Sfn
|
|
|
10
10
|
#
|
|
11
11
|
# @param msg [String]
|
|
12
12
|
def debug(msg)
|
|
13
|
-
if ENV[
|
|
13
|
+
if ENV["DEBUG"] || (respond_to?(:config) && config[:debug])
|
|
14
14
|
puts "<sfn - debug>: #{msg}"
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/sfn/utils/json.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -13,13 +13,13 @@ module Sfn
|
|
|
13
13
|
# @param directory [Miasma::Models::Storage::Directory]
|
|
14
14
|
# @return [String] file path
|
|
15
15
|
def file_store(object, path, directory)
|
|
16
|
-
raise NotImplementedError.new
|
|
16
|
+
raise NotImplementedError.new "Internal updated required! :("
|
|
17
17
|
content = object.is_a?(String) ? object : Utils._format_json(object)
|
|
18
18
|
directory.files.create(
|
|
19
19
|
:identity => path,
|
|
20
20
|
:body => content,
|
|
21
21
|
)
|
|
22
|
-
loc = directory.service.service.name.split(
|
|
22
|
+
loc = directory.service.service.name.split("::").last.downcase
|
|
23
23
|
"#{loc}://#{directory.identity}/#{path}"
|
|
24
24
|
end
|
|
25
25
|
end
|
data/lib/sfn/utils/output.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -15,8 +15,8 @@ module Sfn
|
|
|
15
15
|
def process(things, args = {})
|
|
16
16
|
@event_ids ||= []
|
|
17
17
|
processed = things.reverse.map do |thing|
|
|
18
|
-
next if @event_ids.include?(thing[
|
|
19
|
-
@event_ids.push(thing[
|
|
18
|
+
next if @event_ids.include?(thing["id"])
|
|
19
|
+
@event_ids.push(thing["id"]).compact!
|
|
20
20
|
if args[:attributes]
|
|
21
21
|
args[:attributes].map do |key|
|
|
22
22
|
thing[key].to_s
|
|
@@ -67,7 +67,7 @@ module Sfn
|
|
|
67
67
|
output += process(things, :flat => true, :attributes => allowed_attributes)
|
|
68
68
|
output.compact!
|
|
69
69
|
if output.empty?
|
|
70
|
-
ui.warn
|
|
70
|
+
ui.warn "No information found" unless args.include?(:ignore_empty_output)
|
|
71
71
|
else
|
|
72
72
|
ui.info "#{what.to_s.capitalize} for stack: #{ui.color(stack, :bold)}" if stack
|
|
73
73
|
ui.info "#{ui.list(output, :uneven_columns_across, columns)}"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
|
+
require "pathname"
|
|
3
3
|
|
|
4
4
|
module Sfn
|
|
5
5
|
module Utils
|
|
@@ -13,8 +13,8 @@ module Sfn
|
|
|
13
13
|
# @return [String]
|
|
14
14
|
def humanize_path_basename(path)
|
|
15
15
|
File.basename(path).sub(
|
|
16
|
-
File.extname(path),
|
|
17
|
-
).split(/[-_]/).map(&:capitalize).join(
|
|
16
|
+
File.extname(path), ""
|
|
17
|
+
).split(/[-_]/).map(&:capitalize).join(" ")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Prompt user for file selection
|
|
@@ -27,7 +27,7 @@ module Sfn
|
|
|
27
27
|
# @option opts [String] :filter_prefix only return results matching filter
|
|
28
28
|
# @return [String] file path
|
|
29
29
|
def prompt_for_file(directory, opts = {})
|
|
30
|
-
file_list = Dir.glob(File.join(directory,
|
|
30
|
+
file_list = Dir.glob(File.join(directory, "**", "**", "*")).find_all do |file|
|
|
31
31
|
File.file?(file)
|
|
32
32
|
end
|
|
33
33
|
if opts[:filter_prefix]
|
|
@@ -39,7 +39,7 @@ module Sfn
|
|
|
39
39
|
File.dirname(file)
|
|
40
40
|
end.uniq
|
|
41
41
|
files = file_list.find_all do |path|
|
|
42
|
-
path.sub(directory,
|
|
42
|
+
path.sub(directory, "").split("/").size == 2
|
|
43
43
|
end
|
|
44
44
|
if opts[:ignore_directories]
|
|
45
45
|
directories.delete_if do |dir|
|
|
@@ -47,16 +47,16 @@ module Sfn
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
if directories.empty? && files.empty?
|
|
50
|
-
ui.fatal
|
|
50
|
+
ui.fatal "No formation paths discoverable!"
|
|
51
51
|
else
|
|
52
|
-
output = [
|
|
53
|
-
output <<
|
|
54
|
-
ui.info output.join(
|
|
52
|
+
output = ["Please select an entry"]
|
|
53
|
+
output << "(or directory to list):" unless directories.empty?
|
|
54
|
+
ui.info output.join(" ")
|
|
55
55
|
output.clear
|
|
56
56
|
idx = 1
|
|
57
57
|
valid = {}
|
|
58
58
|
unless directories.empty?
|
|
59
|
-
output << ui.color("#{opts.fetch(:directories_name,
|
|
59
|
+
output << ui.color("#{opts.fetch(:directories_name, "Directories")}:", :bold)
|
|
60
60
|
directories.each do |dir|
|
|
61
61
|
valid[idx] = {:path => dir, :type => :directory}
|
|
62
62
|
output << [idx, humanize_path_basename(dir)]
|
|
@@ -64,7 +64,7 @@ module Sfn
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
unless files.empty?
|
|
67
|
-
output << ui.color("#{opts.fetch(:files_name,
|
|
67
|
+
output << ui.color("#{opts.fetch(:files_name, "Files")}:", :bold)
|
|
68
68
|
files.each do |file|
|
|
69
69
|
valid[idx] = {:path => file, :type => :file}
|
|
70
70
|
output << [idx, humanize_path_basename(file)]
|
|
@@ -74,15 +74,15 @@ module Sfn
|
|
|
74
74
|
max = idx.to_s.length
|
|
75
75
|
output.map! do |o|
|
|
76
76
|
if o.is_a?(Array)
|
|
77
|
-
" #{o.first}.#{
|
|
77
|
+
" #{o.first}.#{" " * (max - o.first.to_s.length)} #{o.last}"
|
|
78
78
|
else
|
|
79
79
|
o
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
ui.info "#{output.join("\n")}\n"
|
|
83
|
-
response = ui.ask_question(
|
|
83
|
+
response = ui.ask_question("Enter selection: ").to_i
|
|
84
84
|
unless valid[response]
|
|
85
|
-
ui.fatal
|
|
85
|
+
ui.fatal "How about using a real value"
|
|
86
86
|
exit 1
|
|
87
87
|
else
|
|
88
88
|
entry = valid[response.to_i]
|
data/lib/sfn/utils/ssher.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -15,10 +15,10 @@ module Sfn
|
|
|
15
15
|
# @return [String, NilClass]
|
|
16
16
|
def remote_file_contents(address, user, path, ssh_opts = {})
|
|
17
17
|
if path.to_s.strip.empty?
|
|
18
|
-
raise ArgumentError.new
|
|
18
|
+
raise ArgumentError.new "No file path provided!"
|
|
19
19
|
end
|
|
20
|
-
require
|
|
21
|
-
content =
|
|
20
|
+
require "net/ssh"
|
|
21
|
+
content = ""
|
|
22
22
|
ssh_session = Net::SSH.start(address, user, ssh_opts)
|
|
23
23
|
content = ssh_session.exec!("sudo cat #{path}")
|
|
24
24
|
content.empty? ? nil : content
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
begin
|
|
2
|
-
require
|
|
2
|
+
require "chef"
|
|
3
3
|
rescue LoadError
|
|
4
4
|
$stderr.puts "WARN: Failed to load Chef. Chef specific features will be disabled!"
|
|
5
5
|
end
|
|
6
|
-
require
|
|
6
|
+
require "sfn"
|
|
7
7
|
|
|
8
8
|
module Sfn
|
|
9
9
|
module Utils
|
|
@@ -14,12 +14,12 @@ module Sfn
|
|
|
14
14
|
include Sfn::Utils::JSON
|
|
15
15
|
|
|
16
16
|
# default chef environment name
|
|
17
|
-
DEFAULT_CHEF_ENVIRONMENT =
|
|
17
|
+
DEFAULT_CHEF_ENVIRONMENT = "_default"
|
|
18
18
|
# default instance options
|
|
19
19
|
DEFAULT_OPTIONS = Mash.new(
|
|
20
20
|
:chef_popsicle => true,
|
|
21
|
-
:ignored_parameters => [
|
|
22
|
-
:chef_environment_parameter =>
|
|
21
|
+
:ignored_parameters => ["Environment", "StackCreator", "Creator"],
|
|
22
|
+
:chef_environment_parameter => "Environment",
|
|
23
23
|
)
|
|
24
24
|
# default structure of export payload
|
|
25
25
|
DEFAULT_EXPORT_STRUCTURE = {
|
|
@@ -33,7 +33,7 @@ module Sfn
|
|
|
33
33
|
),
|
|
34
34
|
:generator => {
|
|
35
35
|
:timestamp => Time.now.to_i,
|
|
36
|
-
:name =>
|
|
36
|
+
:name => "SparkleFormation",
|
|
37
37
|
:version => Sfn::VERSION.version,
|
|
38
38
|
:provider => nil,
|
|
39
39
|
},
|
|
@@ -89,7 +89,7 @@ module Sfn
|
|
|
89
89
|
# @return [Object]
|
|
90
90
|
def method_missing(*args)
|
|
91
91
|
m = args.first.to_s
|
|
92
|
-
if m.end_with?(
|
|
92
|
+
if m.end_with?("?") && options.has_key?(k = m.sub("?", "").to_sym)
|
|
93
93
|
!!options[k]
|
|
94
94
|
else
|
|
95
95
|
super
|
|
@@ -126,7 +126,7 @@ module Sfn
|
|
|
126
126
|
# @return [Chef::Environment]
|
|
127
127
|
def environment
|
|
128
128
|
unless @env
|
|
129
|
-
@env = Chef::Environment.load(
|
|
129
|
+
@env = Chef::Environment.load("_default")
|
|
130
130
|
end
|
|
131
131
|
@env
|
|
132
132
|
end
|
|
@@ -154,9 +154,9 @@ module Sfn
|
|
|
154
154
|
rl_item = item.is_a?(Chef::RunList::RunListItem) ? item : Chef::RunList::RunListItem.new(item)
|
|
155
155
|
static_content = Mash.new(:run_list => [])
|
|
156
156
|
if rl_item.recipe?
|
|
157
|
-
cookbook, recipe = rl_item.name.split(
|
|
157
|
+
cookbook, recipe = rl_item.name.split("::")
|
|
158
158
|
peg_version = allowed_cookbook_version(cookbook)
|
|
159
|
-
static_content[:run_list] << "recipe[#{[cookbook, recipe ||
|
|
159
|
+
static_content[:run_list] << "recipe[#{[cookbook, recipe || "default"].join("::")}@#{peg_version}]"
|
|
160
160
|
elsif rl_item.role?
|
|
161
161
|
role = Chef::Role.load(rl_item.name)
|
|
162
162
|
role.run_list.each do |item|
|
|
@@ -177,10 +177,10 @@ module Sfn
|
|
|
177
177
|
# @param first_run [Hash] chef first run hash
|
|
178
178
|
# @return [Hash]
|
|
179
179
|
def unpack_and_freeze_runlist(first_run)
|
|
180
|
-
extracted_runlists = first_run[
|
|
180
|
+
extracted_runlists = first_run["run_list"].map do |item|
|
|
181
181
|
extract_runlist_item(cf_replace(item))
|
|
182
182
|
end
|
|
183
|
-
first_run.delete(
|
|
183
|
+
first_run.delete("run_list")
|
|
184
184
|
first_run.replace(
|
|
185
185
|
extracted_runlists.inject(first_run) do |memo, first_run_item|
|
|
186
186
|
Chef::Mixin::DeepMerge.merge(memo, first_run_item)
|
|
@@ -208,8 +208,8 @@ module Sfn
|
|
|
208
208
|
result = []
|
|
209
209
|
case thing
|
|
210
210
|
when Hash
|
|
211
|
-
if thing[
|
|
212
|
-
result << thing[
|
|
211
|
+
if thing["content"] && thing["content"]["run_list"]
|
|
212
|
+
result << thing["content"]
|
|
213
213
|
else
|
|
214
214
|
thing.each do |k, v|
|
|
215
215
|
result += locate_runlists(v)
|
|
@@ -230,9 +230,9 @@ module Sfn
|
|
|
230
230
|
def cf_replace(hsh)
|
|
231
231
|
if hsh.is_a?(Hash)
|
|
232
232
|
case hsh.keys.first
|
|
233
|
-
when
|
|
233
|
+
when "Fn::Join"
|
|
234
234
|
cf_join(*hsh.values.first)
|
|
235
|
-
when
|
|
235
|
+
when "Ref"
|
|
236
236
|
cf_ref(hsh.values.first)
|
|
237
237
|
else
|
|
238
238
|
hsh
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -7,9 +7,9 @@ module Sfn
|
|
|
7
7
|
|
|
8
8
|
# Validate attributes within Parameter blocks
|
|
9
9
|
ALLOWED_PARAMETER_ATTRIBUTES = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"Type", "Default", "NoEcho", "AllowedValues", "AllowedPattern",
|
|
11
|
+
"MaxLength", "MinLength", "MaxValue", "MinValue", "Description",
|
|
12
|
+
"ConstraintDescription",
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
# Clean the parameters of the template
|
|
@@ -17,14 +17,14 @@ module Sfn
|
|
|
17
17
|
# @param template [Hash]
|
|
18
18
|
# @return [Hash] template
|
|
19
19
|
def parameter_scrub!(template)
|
|
20
|
-
parameters = template[
|
|
20
|
+
parameters = template["Parameters"]
|
|
21
21
|
if parameters
|
|
22
22
|
parameters.each do |name, options|
|
|
23
23
|
options.delete_if do |attribute, value|
|
|
24
24
|
!ALLOWED_PARAMETER_ATTRIBUTES.include?(attribute)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
|
-
template[
|
|
27
|
+
template["Parameters"] = parameters
|
|
28
28
|
end
|
|
29
29
|
template
|
|
30
30
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sfn"
|
|
2
2
|
|
|
3
3
|
module Sfn
|
|
4
4
|
module Utils
|
|
@@ -9,34 +9,34 @@ module Sfn
|
|
|
9
9
|
|
|
10
10
|
# HOT parameter mapping
|
|
11
11
|
HEAT_CONSTRAINT_MAP = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
"MaxLength" => [:length, :max],
|
|
13
|
+
"MinLength" => [:length, :min],
|
|
14
|
+
"MaxValue" => [:range, :max],
|
|
15
|
+
"MinValue" => [:range, :min],
|
|
16
|
+
"AllowedValues" => [:allowed_values],
|
|
17
|
+
"AllowedPattern" => [:allowed_pattern],
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
# GCDM parameter mapping
|
|
21
21
|
GOOGLE_CONSTRAINT_MAP = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"AllowedPattern" => [:pattern],
|
|
23
|
+
"MaxValue" => [:maximum],
|
|
24
|
+
"MinValue" => [:minimum],
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
# Parameter mapping identifier and content
|
|
28
28
|
PARAMETER_DEFINITION_MAP = {
|
|
29
|
-
|
|
29
|
+
"constraints" => HEAT_CONSTRAINT_MAP,
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
# Supported parameter validations
|
|
33
33
|
PARAMETER_VALIDATIONS = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
"allowed_values",
|
|
35
|
+
"allowed_pattern",
|
|
36
|
+
"max_length",
|
|
37
|
+
"min_length",
|
|
38
|
+
"max_value",
|
|
39
|
+
"min_value",
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
# Validate a parameters
|
|
@@ -51,12 +51,12 @@ module Sfn
|
|
|
51
51
|
# @option parameter_definition [String, Integer] 'MinValue'
|
|
52
52
|
# @return [TrueClass, Array<String>] true if valid. array of string errors if invalid
|
|
53
53
|
def validate_parameter(value, parameter_definition)
|
|
54
|
-
return [[:blank,
|
|
54
|
+
return [[:blank, "Value cannot be blank"]] if value.to_s.strip.empty?
|
|
55
55
|
parameter_definition = reformat_definition(parameter_definition)
|
|
56
|
-
value_list = list_type?(parameter_definition.fetch(
|
|
56
|
+
value_list = list_type?(parameter_definition.fetch("Type", parameter_definition["type"].to_s)) ? value.to_s.split(",") : [value]
|
|
57
57
|
result = PARAMETER_VALIDATIONS.map do |validator_key|
|
|
58
58
|
valid_key = parameter_definition.keys.detect do |pdef_key|
|
|
59
|
-
pdef_key.downcase.gsub(
|
|
59
|
+
pdef_key.downcase.gsub("_", "") == validator_key.downcase.gsub("_", "")
|
|
60
60
|
end
|
|
61
61
|
if valid_key
|
|
62
62
|
value_list.map do |value|
|
|
@@ -102,7 +102,7 @@ module Sfn
|
|
|
102
102
|
if pdef.include?(value)
|
|
103
103
|
true
|
|
104
104
|
else
|
|
105
|
-
"Not an allowed value: #{pdef.join(
|
|
105
|
+
"Not an allowed value: #{pdef.join(", ")}"
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -182,7 +182,7 @@ module Sfn
|
|
|
182
182
|
# @return [TrueClass, FalseClass]
|
|
183
183
|
def list_type?(type)
|
|
184
184
|
type = type.downcase
|
|
185
|
-
type.start_with?(
|
|
185
|
+
type.start_with?("comma") || type.start_with?("list<")
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
188
|
end
|
data/lib/sfn/version.rb
CHANGED
data/sfn.gemspec
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) +
|
|
2
|
-
require
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + "/lib/"
|
|
2
|
+
require "sfn/version"
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
|
-
s.name =
|
|
4
|
+
s.name = "sfn"
|
|
5
5
|
s.version = Sfn::VERSION.version
|
|
6
|
-
s.summary =
|
|
7
|
-
s.author =
|
|
8
|
-
s.email =
|
|
9
|
-
s.homepage =
|
|
10
|
-
s.description =
|
|
11
|
-
s.license =
|
|
12
|
-
s.require_path =
|
|
13
|
-
s.add_runtime_dependency
|
|
14
|
-
s.add_runtime_dependency
|
|
15
|
-
s.add_runtime_dependency
|
|
16
|
-
s.add_runtime_dependency
|
|
17
|
-
s.add_runtime_dependency
|
|
18
|
-
s.add_runtime_dependency
|
|
19
|
-
s.add_runtime_dependency
|
|
20
|
-
s.add_runtime_dependency
|
|
21
|
-
s.add_runtime_dependency
|
|
22
|
-
s.add_runtime_dependency
|
|
23
|
-
s.add_runtime_dependency
|
|
24
|
-
s.add_runtime_dependency
|
|
25
|
-
s.add_runtime_dependency
|
|
26
|
-
s.add_runtime_dependency
|
|
27
|
-
s.add_development_dependency
|
|
28
|
-
s.add_development_dependency
|
|
29
|
-
s.add_development_dependency
|
|
30
|
-
s.add_development_dependency
|
|
31
|
-
s.add_development_dependency
|
|
32
|
-
s.add_development_dependency
|
|
33
|
-
s.executables <<
|
|
34
|
-
s.files = Dir[
|
|
6
|
+
s.summary = "SparkleFormation CLI"
|
|
7
|
+
s.author = "Chris Roberts"
|
|
8
|
+
s.email = "code@chrisroberts.org"
|
|
9
|
+
s.homepage = "http://github.com/sparkleformation/sfn"
|
|
10
|
+
s.description = "SparkleFormation CLI"
|
|
11
|
+
s.license = "Apache-2.0"
|
|
12
|
+
s.require_path = "lib"
|
|
13
|
+
s.add_runtime_dependency "bogo-cli", ">= 0.2.5", "< 0.4"
|
|
14
|
+
s.add_runtime_dependency "bogo-ui", ">= 0.1.28", "< 0.4"
|
|
15
|
+
s.add_runtime_dependency "miasma", ">= 0.3.3", "< 0.4"
|
|
16
|
+
s.add_runtime_dependency "miasma-aws", ">= 0.3.15", "< 0.4"
|
|
17
|
+
s.add_runtime_dependency "miasma-azure", ">= 0.1.0", "< 0.3"
|
|
18
|
+
s.add_runtime_dependency "miasma-open-stack", ">= 0.1.0", "< 0.3"
|
|
19
|
+
s.add_runtime_dependency "miasma-rackspace", ">= 0.1.0", "< 0.3"
|
|
20
|
+
s.add_runtime_dependency "miasma-google", ">= 0.1.0", "< 0.3"
|
|
21
|
+
s.add_runtime_dependency "miasma-terraform", ">= 0.1.0", "< 0.2.0"
|
|
22
|
+
s.add_runtime_dependency "jmespath"
|
|
23
|
+
s.add_runtime_dependency "net-ssh"
|
|
24
|
+
s.add_runtime_dependency "sparkle_formation", ">= 3.0.11", "< 4"
|
|
25
|
+
s.add_runtime_dependency "hashdiff", "~> 0.2.2"
|
|
26
|
+
s.add_runtime_dependency "graph", "~> 2.8.1"
|
|
27
|
+
s.add_development_dependency "rake", "~> 10"
|
|
28
|
+
s.add_development_dependency "minitest"
|
|
29
|
+
s.add_development_dependency "rspec", "~> 3.5"
|
|
30
|
+
s.add_development_dependency "rufo", "~> 0.3.0"
|
|
31
|
+
s.add_development_dependency "mocha"
|
|
32
|
+
s.add_development_dependency "yard"
|
|
33
|
+
s.executables << "sfn"
|
|
34
|
+
s.files = Dir["{lib,bin,docs}/**/*"] + %w(sfn.gemspec README.md CHANGELOG.md LICENSE)
|
|
35
35
|
end
|