sfn 0.3.8 → 0.4.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: ccd51de01219d49eab04ff9c65a559496d12af4e
4
- data.tar.gz: 54531dc80ac6f15fe3c712449533e74ea6c2706f
3
+ metadata.gz: 0c3196ce66fd00b722a64b80efff9ed0cdd47103
4
+ data.tar.gz: 4a1d7fb290a7908253b92f4c822f70f5f0463b11
5
5
  SHA512:
6
- metadata.gz: e8fd31d72271d235c0e2a267cb0f978a95a61f0182cdebfed3e2e763efaa6a4222ab62c02d75e4544b8556f9a6dd5d941f120ffab01aa7b2743cc5996eb977f9
7
- data.tar.gz: 4355c6cd7c2c75537c3c120bf5a961e1cd46e6483c3101ba144b12e2bcd0d273458300d8b2e3def53f10712fd93cdf5e67ec6907d04133eea6341da4790df3a0
6
+ metadata.gz: eaec77115434aa9b9c984b7148e4cdd691838ccc97843b9a1ca323cd1beb2fcd552f82f39713f2cbad054771ba204b50a7bd2deca8cae22cf723771e9ae03fdf
7
+ data.tar.gz: 14110bca18d73ca198d2f1514be1446710283e6efbddada42fe75299cbf6ae73fba4fd7ca45ba0d20c240de897685f8aa9b26b0bdcd5e280075663bd2ccf1623
@@ -1,3 +1,14 @@
1
+ ## v0.4.0
2
+ * Fix parameters passed on CLI (#11)
3
+ * Fix credential overrides from the CLI (#14)
4
+ * Properly process CLI options through custom config classes
5
+ * Include AWS STS support via miasma-aws version bump
6
+
7
+ ***NOTE***: Some CLI **short** flags have changed in this release. This is due to
8
+ some updates on flag generation to help keep things more
9
+ consistent now and into the future. Please refer to the help
10
+ output for a given command to view short flags.
11
+
1
12
  ## v0.3.8
2
13
  * Fix result output from `update` command (#9)
3
14
  * Fix `inspect` command to properly support multiple attribute flags
@@ -48,5 +48,15 @@ module Sfn
48
48
  opts
49
49
  end
50
50
 
51
+ # @return [Class] attempt to return customized configuration class
52
+ def config_class
53
+ klass_name = self.class.name.split('::').last
54
+ if(Sfn::Config.const_defined?(klass_name))
55
+ Sfn::Config.const_get(klass_name)
56
+ else
57
+ super
58
+ end
59
+ end
60
+
51
61
  end
52
62
  end
@@ -107,39 +107,50 @@ module Sfn
107
107
  # @param stack [Hash] stack template
108
108
  # @return [Hash]
109
109
  def populate_parameters!(stack, current_params={})
110
- if(config[:interactive_parameters])
111
- if(stack['Parameters'])
112
- unless(config.get(:parameters))
113
- config.set(:parameters, Smash.new)
114
- end
115
- stack.fetch('Parameters', {}).each do |k,v|
116
- next if config[:parameters][k]
117
- attempt = 0
118
- valid = false
119
- until(valid)
120
- attempt += 1
121
- default = config[:parameters].fetch(
122
- k, current_params.fetch(
123
- k, v['Default']
124
- )
110
+ if(stack['Parameters'])
111
+ if(config.get(:parameter).is_a?(Array))
112
+ config[:parameter] = Smash[
113
+ *config.get(:parameter).map(&:to_a)
114
+ ]
115
+ end
116
+ if(config.get(:parameters))
117
+ config.set(:parameters,
118
+ config.get(:parameters).merge(config[:parameter])
119
+ )
120
+ else
121
+ config.set(:parameters, config.fetch(:parameter, Smash.new))
122
+ end
123
+ stack.fetch('Parameters', {}).each do |k,v|
124
+ next if config[:parameters][k]
125
+ attempt = 0
126
+ valid = false
127
+ until(valid)
128
+ attempt += 1
129
+ default = config[:parameters].fetch(
130
+ k, current_params.fetch(
131
+ k, v['Default']
125
132
  )
133
+ )
134
+ if(config[:interactive_parameters])
126
135
  answer = ui.ask_question("#{k.split(/([A-Z]+[^A-Z]*)/).find_all{|s|!s.empty?}.join(' ')}", :default => default)
127
- validation = Sfn::Utils::StackParameterValidator.validate(answer, v)
128
- if(validation == true)
129
- unless(answer == v['Default'])
130
- config[:parameters][k] = answer
131
- end
132
- valid = true
133
- else
134
- validation.each do |validation_error|
135
- ui.error validation_error.last
136
- end
136
+ else
137
+ answer = default
138
+ end
139
+ validation = Sfn::Utils::StackParameterValidator.validate(answer, v)
140
+ if(validation == true)
141
+ unless(answer == v['Default'])
142
+ config[:parameters][k] = answer
137
143
  end
138
- if(attempt > MAX_PARAMETER_ATTEMPTS)
139
- ui.fatal 'Failed to receive allowed parameter!'
140
- exit 1
144
+ valid = true
145
+ else
146
+ validation.each do |validation_error|
147
+ ui.error validation_error.last
141
148
  end
142
149
  end
150
+ if(attempt > MAX_PARAMETER_ATTEMPTS)
151
+ ui.fatal 'Failed to receive allowed parameter!'
152
+ exit 1
153
+ end
143
154
  end
144
155
  end
145
156
  end
@@ -22,11 +22,22 @@ module Sfn
22
22
  autoload :Update, 'sfn/config/update'
23
23
  autoload :Validate, 'sfn/config/validate'
24
24
 
25
+ attribute(
26
+ :config, String,
27
+ :description => 'Configuration file path'
28
+ )
29
+
25
30
  attribute(
26
31
  :credentials, Smash,
27
32
  :coerce => proc{|v|
28
- v = Smash[v.split(',').map{|x| v.split('=')}] if v.is_a?(String)
29
- v.to_smash
33
+ case v
34
+ when String
35
+ Smash[v.split(',').map{|x| v.split(/[=:]/)}]
36
+ when Hash
37
+ v.to_smash
38
+ else
39
+ v
40
+ end
30
41
  },
31
42
  :description => 'Provider credentials'
32
43
  )
@@ -53,10 +64,6 @@ module Sfn
53
64
  :yes, [TrueClass, FalseClass],
54
65
  :description => 'Automatically accept any requests for confirmation'
55
66
  )
56
- attribute(
57
- :config, String,
58
- :description => 'Configuration file path'
59
- )
60
67
 
61
68
  attribute :create, Create, :coerce => proc{|v| Create.new(v)}
62
69
  attribute :update, Update, :coerce => proc{|v| Update.new(v)}
@@ -76,9 +83,7 @@ module Sfn
76
83
  # @return [Smash]
77
84
  def self.options_for(klass)
78
85
  shorts = ['h'] # always reserve `-h` for help
79
- _options_for(self, shorts).merge(
80
- _options_for(klass, shorts)
81
- )
86
+ _options_for(klass, shorts)
82
87
  end
83
88
 
84
89
  # Provide options for config class
@@ -88,7 +93,11 @@ module Sfn
88
93
  # @return [Smash]
89
94
  def self._options_for(klass, shorts)
90
95
  Smash[
91
- klass.attributes.sort_by(&:first).map do |name, info|
96
+ ([klass] + klass.ancestors).map do |a|
97
+ if(a.ancestors.include?(Bogo::Config) && !a.attributes.empty?)
98
+ a.attributes
99
+ end
100
+ end.compact.reverse.inject(Smash.new){|m, n| m.deep_merge(n)}.map do |name, info|
92
101
  next unless info[:description]
93
102
  short = name.chars.zip(name.chars.map(&:upcase)).flatten.detect do |c|
94
103
  !shorts.include?(c)
@@ -2,7 +2,7 @@ require 'sfn'
2
2
 
3
3
  module Sfn
4
4
  class Config
5
- class Describe < Bogo::Config
5
+ class Describe < Config
6
6
 
7
7
  attribute(
8
8
  :resources, [TrueClass, FalseClass],
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # Destroy command configuration
6
- class Destroy < Bogo::Config
6
+ class Destroy < Config
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # Events command configuration
6
- class Events < Bogo::Config
6
+ class Events < Config
7
7
 
8
8
  attribute(
9
9
  :attribute, String,
@@ -4,7 +4,7 @@ module Sfn
4
4
  class Config
5
5
 
6
6
  # Export command configuration
7
- class Export < Bogo::Config
7
+ class Export < Config
8
8
 
9
9
  attribute(
10
10
  :name, String,
@@ -4,7 +4,7 @@ module Sfn
4
4
  class Config
5
5
 
6
6
  # Import command configuration
7
- class Import < Bogo::Config
7
+ class Import < Config
8
8
 
9
9
  attribute(
10
10
  :path, String,
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # Inspect command configuration
6
- class Inspect < Bogo::Config
6
+ class Inspect < Config
7
7
 
8
8
  attribute(
9
9
  :attribute, String,
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # List command configuration
6
- class List < Bogo::Config
6
+ class List < Sfn::Config
7
7
 
8
8
  attribute(
9
9
  :attribute, String,
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # Promote command configuration
6
- class Promote < Bogo::Config
6
+ class Promote < Config
7
7
 
8
8
  attribute(
9
9
  :accounts, String,
@@ -14,6 +14,14 @@ module Sfn
14
14
  :multiple => true,
15
15
  :description => 'Apply outputs from stack to input parameters'
16
16
  )
17
+ attribute(
18
+ :parameter, Smash,
19
+ :multiple => true,
20
+ :description => 'Pass template parameters directly (ParamName:ParamValue)',
21
+ :coerce => lambda{|v|
22
+ v.is_a?(String) ? Smash[*v.split(/[=:]/, 2)] : v
23
+ }
24
+ )
17
25
 
18
26
  end
19
27
  end
@@ -3,7 +3,7 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  # Validate command configuration
6
- class Validate < Bogo::Config
6
+ class Validate < Config
7
7
 
8
8
  attribute(
9
9
  :processing, [TrueClass, FalseClass],
@@ -1,4 +1,4 @@
1
1
  module Sfn
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.3.8')
3
+ VERSION = Gem::Version.new('0.4.0')
4
4
  end
@@ -10,9 +10,9 @@ 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_dependency 'bogo-cli', '~> 0.1.16'
13
+ s.add_dependency 'bogo-cli', '~> 0.1.21'
14
14
  s.add_dependency 'miasma', '~> 0.2.20'
15
- s.add_dependency 'miasma-aws', '~> 0.1.8'
15
+ s.add_dependency 'miasma-aws', '~> 0.1.16'
16
16
  s.add_dependency 'net-ssh'
17
17
  s.add_dependency 'sparkle_formation', '>= 0.2.8'
18
18
  s.executables << 'sfn'
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.3.8
4
+ version: 0.4.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-04-23 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bogo-cli
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.16
19
+ version: 0.1.21
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.16
26
+ version: 0.1.21
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: miasma
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.8
47
+ version: 0.1.16
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.8
54
+ version: 0.1.16
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: net-ssh
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -162,4 +162,3 @@ signing_key:
162
162
  specification_version: 4
163
163
  summary: SparkleFormation CLI
164
164
  test_files: []
165
- has_rdoc: