sfn 2.1.12 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1998884aef2f32da686903df01d5dbcd702e134d
4
- data.tar.gz: 2d4cd76d833eaf5db2e3d05d69e815546d092b9f
3
+ metadata.gz: 082256b2f072109b58b33fce652d587d05d04862
4
+ data.tar.gz: b77d62ca66d3999d4de96f6dfea3bed304efd463
5
5
  SHA512:
6
- metadata.gz: 6c7021222f98ebbf2587d876172d02ee49e20c5eca73be13862ccb332c1674c4be34031963a69ff9dcf6739e9497e0d0ae4b8b778911d0e1b9e3946c350352c3
7
- data.tar.gz: 30fbcb41c8291f6e77231c4c372d3a85d32dae4280a733efae28f64ab79bb966dc881dc7b52e5d11ed9e72343f4958d573b6289b166639a9f2126f7d76f77fdb
6
+ metadata.gz: 6c59bdbe48b6cf3f48c007413a36511e83ebc64acc1ab050d25bf8069927d13642032dbb93f9a22cb70e10955780237717b22a70128e6966ac7e2f4860a41f82
7
+ data.tar.gz: ddc99d40040b35e2920c55dde47f85ddcfa3ae3d64b6e0d9e7fc9d0b0841d9072d9de263b9787ee6be37acc1e38c8ff124d3f7a067843aa32d95da9182ccfb0b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v2.2.0
2
+ * [enhancement] Properly support list types when validating (#167)
3
+ * [enhancement] Restrict automatic gem loading when `:sfn` group is present (#175)
4
+ * [enhancement] Support loading configuration files with type extensions (#168)
5
+
1
6
  # v2.1.12
2
7
  * [fix] Provide useful error message when nesting_bucket is unset (#159)
3
8
  * [fix] Properly locate templates when relative path provided (#160)
data/bin/sfn CHANGED
@@ -5,7 +5,11 @@ require 'sfn'
5
5
 
6
6
  if(defined?(Bundler))
7
7
  begin
8
- Bundler.require
8
+ if(Bundler.definition.groups.include?(:sfn))
9
+ Bundler.require(:sfn)
10
+ else
11
+ Bundler.require
12
+ end
9
13
  rescue Bundler::GemfileNotFound
10
14
  # ignore load error
11
15
  end
data/lib/sfn/command.rb CHANGED
@@ -23,6 +23,19 @@ module Sfn
23
23
  autoload :Update, 'sfn/command/update'
24
24
  autoload :Validate, 'sfn/command/validate'
25
25
 
26
+ # Base name of configuration file
27
+ CONFIG_BASE_NAME = '.sfn'
28
+
29
+ # Supported configuration file extensions
30
+ VALID_CONFIG_EXTENSIONS = [
31
+ '',
32
+ '.rb',
33
+ '.json',
34
+ '.yaml',
35
+ '.yml',
36
+ '.xml'
37
+ ]
38
+
26
39
  # Override to provide config file searching
27
40
  def initialize(cli_opts, args)
28
41
  unless(cli_opts['config'])
@@ -52,13 +65,19 @@ module Sfn
52
65
  # @return [Slop]
53
66
  def discover_config(opts)
54
67
  cwd = Dir.pwd.split(File::SEPARATOR)
55
- until(cwd.empty? || File.exists?(cwd.push('.sfn').join(File::SEPARATOR)))
56
- cwd.pop(2)
68
+ detected_path = ''
69
+ until(cwd.empty? || File.exists?(detected_path.to_s))
70
+ detected_path = Dir.glob(
71
+ (cwd + ["#{CONFIG_BASE_NAME}{#{VALID_CONFIG_EXTENSIONS.join(',')}}"]).join(
72
+ File::SEPARATOR
73
+ )
74
+ ).first
75
+ cwd.pop
57
76
  end
58
77
  if(opts.respond_to?(:fetch_option))
59
- opts.fetch_option('config').value = cwd.join(File::SEPARATOR) unless cwd.empty?
78
+ opts.fetch_option('config').value = detected_path if detected_path
60
79
  else
61
- opts['config'] = cwd.join(File::SEPARATOR) unless cwd.empty?
80
+ opts['config'] = detected_path if detected_path
62
81
  end
63
82
  opts
64
83
  end
@@ -17,7 +17,7 @@ module Sfn
17
17
  name_required!
18
18
  stack_name = name_args.last
19
19
  root_stack = api_action! do
20
- provider.connection.stacks.get(stack_name)
20
+ provider.stack(stack_name)
21
21
  end
22
22
  if(root_stack)
23
23
  ([root_stack] + root_stack.nested_stacks).compact.each do |stack|
@@ -37,7 +37,7 @@ module Sfn
37
37
  end
38
38
  else
39
39
  ui.fatal "Failed to find requested stack: #{ui.color(stack_name, :bold, :red)}"
40
- exit -1
40
+ raise "Requested stack not found: #{stack_name}"
41
41
  end
42
42
  end
43
43
 
@@ -89,7 +89,7 @@ module Sfn
89
89
  # @param stack [Miasma::Models::Orchestration::Stack]
90
90
  def tags(stack)
91
91
  ui.info "Tags for stack: #{ui.color(stack.name, :bold)}"
92
- unless(stack.tags.empty?)
92
+ if(stack.tags && !stack.tags.empty?)
93
93
  stack.tags.each do |key, value|
94
94
  ui.info [' ', ui.color("#{key}:", :bold), value].join(' ')
95
95
  end
@@ -21,7 +21,7 @@ module Sfn
21
21
  # @return [KnifeCloudformation::Provider]
22
22
  def provider
23
23
  begin
24
- memoize(:provider, :direct) do
24
+ memoize(:provider) do
25
25
  result = Sfn::Provider.new(
26
26
  :miasma => config[:credentials],
27
27
  :async => false,
data/lib/sfn/provider.rb CHANGED
@@ -94,7 +94,7 @@ module Sfn
94
94
 
95
95
  # @return [String] json representation of cached stacks
96
96
  def cached_stacks(stack_id=nil)
97
- unless(@initial_fetch_complete || stack_id)
97
+ if(!@initial_fetch_complete || stack_id)
98
98
  recache = true
99
99
  if(stack_id && @initial_fetch_complete)
100
100
  recache = !!stacks.get(stack_id)
@@ -48,17 +48,20 @@ module Sfn
48
48
  def validate(value, parameter_definition)
49
49
  return [[:blank, 'Value cannot be blank']] if value.to_s.strip.empty?
50
50
  parameter_definition = reformat_definition(parameter_definition)
51
+ value_list = list_type?(parameter_definition.fetch('Type', parameter_definition['type'].to_s)) ? value.to_s.split(',') : [value]
51
52
  result = PARAMETER_VALIDATIONS.map do |validator_key|
52
53
  valid_key = parameter_definition.keys.detect do |pdef_key|
53
54
  pdef_key.downcase.gsub('_', '') == validator_key.downcase.gsub('_', '')
54
55
  end
55
56
  if(valid_key)
56
- res = self.send(validator_key, value, parameter_definition[valid_key])
57
- res == true ? true : [validator_key, res]
57
+ value_list.map do |value|
58
+ res = self.send(validator_key, value, parameter_definition[valid_key])
59
+ res == true ? true : [validator_key, res]
60
+ end
58
61
  else
59
62
  true
60
63
  end
61
- end
64
+ end.flatten(1)
62
65
  result.delete_if{|x| x == true}
63
66
  result.empty? ? true : result
64
67
  end
@@ -105,7 +108,7 @@ module Sfn
105
108
  # @option pdef [String] 'AllowedPattern'
106
109
  # @return [TrueClass, String]
107
110
  def allowed_pattern(value, pdef)
108
- if(value.match(/#{pdef}/))
111
+ if(value.match(%r{#{pdef}}))
109
112
  true
110
113
  else
111
114
  "Not a valid pattern. Must match: #{pdef}"
@@ -168,6 +171,15 @@ module Sfn
168
171
  end
169
172
  end
170
173
 
174
+ # Check if type is a list type
175
+ #
176
+ # @param type [String]
177
+ # @return [TrueClass, FalseClass]
178
+ def list_type?(type)
179
+ type = type.downcase
180
+ type.start_with?('comma') || type.start_with?('list<')
181
+ end
182
+
171
183
  end
172
184
  end
173
185
  end
data/lib/sfn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Sfn
2
2
  # Current library version
3
- VERSION = Gem::Version.new('2.1.12')
3
+ VERSION = Gem::Version.new('2.2.0')
4
4
  end
data/sfn.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = 'SparkleFormation CLI'
11
11
  s.license = 'Apache-2.0'
12
12
  s.require_path = 'lib'
13
- s.add_runtime_dependency 'bogo-cli', '>= 0.2.4', '< 0.4'
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
16
  s.add_runtime_dependency 'miasma-aws', '>= 0.3.0', '< 0.4'
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: 2.1.12
4
+ version: 2.2.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-03-17 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bogo-cli
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.4
19
+ version: 0.2.5
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0.4'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.2.4
29
+ version: 0.2.5
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0.4'