sfn 3.0.28 → 3.0.30

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.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/docs/callbacks.md +1 -0
  4. data/lib/chef/knife/knife_plugin_seed.rb +11 -17
  5. data/lib/sfn.rb +0 -2
  6. data/lib/sfn/api_provider.rb +0 -2
  7. data/lib/sfn/api_provider/google.rb +6 -9
  8. data/lib/sfn/api_provider/terraform.rb +4 -6
  9. data/lib/sfn/cache.rb +36 -39
  10. data/lib/sfn/callback.rb +0 -2
  11. data/lib/sfn/callback/aws_assume_role.rb +7 -8
  12. data/lib/sfn/callback/aws_mfa.rb +7 -8
  13. data/lib/sfn/callback/stack_policy.rb +15 -17
  14. data/lib/sfn/command.rb +9 -11
  15. data/lib/sfn/command/conf.rb +7 -10
  16. data/lib/sfn/command/create.rb +8 -12
  17. data/lib/sfn/command/describe.rb +6 -8
  18. data/lib/sfn/command/destroy.rb +8 -10
  19. data/lib/sfn/command/diff.rb +18 -25
  20. data/lib/sfn/command/events.rb +15 -16
  21. data/lib/sfn/command/export.rb +13 -17
  22. data/lib/sfn/command/graph.rb +11 -13
  23. data/lib/sfn/command/graph/aws.rb +27 -29
  24. data/lib/sfn/command/graph/terraform.rb +22 -23
  25. data/lib/sfn/command/import.rb +13 -16
  26. data/lib/sfn/command/init.rb +5 -7
  27. data/lib/sfn/command/inspect.rb +26 -29
  28. data/lib/sfn/command/lint.rb +10 -12
  29. data/lib/sfn/command/list.rb +5 -8
  30. data/lib/sfn/command/print.rb +3 -5
  31. data/lib/sfn/command/promote.rb +0 -2
  32. data/lib/sfn/command/update.rb +42 -46
  33. data/lib/sfn/command/validate.rb +4 -6
  34. data/lib/sfn/command_module/base.rb +17 -25
  35. data/lib/sfn/command_module/callbacks.rb +12 -8
  36. data/lib/sfn/command_module/stack.rb +39 -43
  37. data/lib/sfn/command_module/template.rb +89 -90
  38. data/lib/sfn/config.rb +30 -31
  39. data/lib/sfn/config/conf.rb +1 -3
  40. data/lib/sfn/config/create.rb +5 -7
  41. data/lib/sfn/config/describe.rb +3 -5
  42. data/lib/sfn/config/diff.rb +1 -1
  43. data/lib/sfn/config/events.rb +6 -8
  44. data/lib/sfn/config/export.rb +4 -7
  45. data/lib/sfn/config/graph.rb +4 -6
  46. data/lib/sfn/config/import.rb +3 -5
  47. data/lib/sfn/config/init.rb +0 -1
  48. data/lib/sfn/config/inspect.rb +7 -9
  49. data/lib/sfn/config/lint.rb +4 -4
  50. data/lib/sfn/config/list.rb +3 -5
  51. data/lib/sfn/config/print.rb +3 -5
  52. data/lib/sfn/config/promote.rb +3 -5
  53. data/lib/sfn/config/update.rb +10 -12
  54. data/lib/sfn/config/validate.rb +18 -20
  55. data/lib/sfn/lint.rb +0 -2
  56. data/lib/sfn/lint/definition.rb +3 -5
  57. data/lib/sfn/lint/rule.rb +7 -8
  58. data/lib/sfn/lint/rule_set.rb +11 -20
  59. data/lib/sfn/monkey_patch/stack.rb +32 -34
  60. data/lib/sfn/monkey_patch/stack/azure.rb +0 -1
  61. data/lib/sfn/monkey_patch/stack/google.rb +15 -16
  62. data/lib/sfn/planner.rb +1 -3
  63. data/lib/sfn/planner/aws.rb +82 -89
  64. data/lib/sfn/provider.rb +21 -23
  65. data/lib/sfn/utils.rb +0 -2
  66. data/lib/sfn/utils/debug.rb +1 -2
  67. data/lib/sfn/utils/json.rb +3 -2
  68. data/lib/sfn/utils/object_storage.rb +1 -2
  69. data/lib/sfn/utils/output.rb +8 -9
  70. data/lib/sfn/utils/path_selector.rb +9 -10
  71. data/lib/sfn/utils/ssher.rb +2 -3
  72. data/lib/sfn/utils/stack_exporter.rb +20 -21
  73. data/lib/sfn/utils/stack_parameter_scrubber.rb +6 -7
  74. data/lib/sfn/utils/stack_parameter_validator.rb +14 -16
  75. data/lib/sfn/version.rb +1 -1
  76. data/sfn.gemspec +1 -1
  77. metadata +8 -8
@@ -13,14 +13,14 @@ module Sfn
13
13
  # @param type [Class, Array<Class>] valid types
14
14
  # @param info [Hash] attribute information
15
15
  # @return [Hash]
16
- def self.attribute(name, type, info=Smash.new)
17
- if([type].flatten.any?{|t| t.ancestors.include?(Hash)})
18
- unless(info[:coerce])
16
+ def self.attribute(name, type, info = Smash.new)
17
+ if [type].flatten.any? { |t| t.ancestors.include?(Hash) }
18
+ unless info[:coerce]
19
19
  info[:coerce] = lambda do |v|
20
20
  case v
21
21
  when String
22
22
  Smash[
23
- v.split(',').map do |item_pair|
23
+ v.split(/,(?=[^,]*:)/).map do |item_pair|
24
24
  item_pair.split(/[=:]/, 2)
25
25
  end
26
26
  ]
@@ -62,65 +62,65 @@ module Sfn
62
62
  attribute(
63
63
  :config, String,
64
64
  :description => 'Configuration file path',
65
- :short_flag => 'c'
65
+ :short_flag => 'c',
66
66
  )
67
67
 
68
68
  attribute(
69
69
  :credentials, Smash,
70
70
  :description => 'Provider credentials',
71
- :short_flag => 'C'
71
+ :short_flag => 'C',
72
72
  )
73
73
  attribute(
74
74
  :ignore_parameters, String,
75
75
  :multiple => true,
76
76
  :description => 'Parameters to ignore during modifications',
77
- :short_flag => 'i'
77
+ :short_flag => 'i',
78
78
  )
79
79
  attribute(
80
80
  :interactive_parameters, [TrueClass, FalseClass],
81
81
  :default => true,
82
82
  :description => 'Prompt for template parameters',
83
- :short_flag => 'I'
83
+ :short_flag => 'I',
84
84
  )
85
85
  attribute(
86
86
  :poll, [TrueClass, FalseClass],
87
87
  :default => true,
88
88
  :description => 'Poll stack events on modification actions',
89
- :short_flag => 'p'
89
+ :short_flag => 'p',
90
90
  )
91
91
  attribute(
92
92
  :defaults, [TrueClass, FalseClass],
93
93
  :description => 'Automatically accept default values',
94
- :short_flag => 'd'
94
+ :short_flag => 'd',
95
95
  )
96
96
  attribute(
97
97
  :yes, [TrueClass, FalseClass],
98
98
  :description => 'Automatically accept any requests for confirmation',
99
- :short_flag => 'y'
99
+ :short_flag => 'y',
100
100
  )
101
101
  attribute(
102
102
  :debug, [TrueClass, FalseClass],
103
103
  :description => 'Enable debug output',
104
- :short_flag => 'u'
104
+ :short_flag => 'u',
105
105
  )
106
106
  attribute(
107
107
  :colors, [TrueClass, FalseClass],
108
108
  :description => 'Enable colorized output',
109
- :default => true
109
+ :default => true,
110
110
  )
111
111
 
112
- attribute :conf, Conf, :coerce => proc{|v| Conf.new(v)}
113
- attribute :create, Create, :coerce => proc{|v| Create.new(v)}
114
- attribute :update, Update, :coerce => proc{|v| Update.new(v)}
115
- attribute :destroy, Destroy, :coerce => proc{|v| Destroy.new(v)}
116
- attribute :events, Events, :coerce => proc{|v| Events.new(v)}
117
- attribute :export, Export, :coerce => proc{|v| Export.new(v)}
118
- attribute :import, Import, :coerce => proc{|v| Import.new(v)}
119
- attribute :inspect, Inspect, :coerce => proc{|v| Inpsect.new(v)}
120
- attribute :describe, Describe, :coerce => proc{|v| Describe.new(v)}
121
- attribute :list, List, :coerce => proc{|v| List.new(v)}
122
- attribute :promote, Promote, :coerce => proc{|v| Promote.new(v)}
123
- attribute :validate, Validate, :coerce => proc{|v| Validate.new(v)}
112
+ attribute :conf, Conf, :coerce => proc { |v| Conf.new(v) }
113
+ attribute :create, Create, :coerce => proc { |v| Create.new(v) }
114
+ attribute :update, Update, :coerce => proc { |v| Update.new(v) }
115
+ attribute :destroy, Destroy, :coerce => proc { |v| Destroy.new(v) }
116
+ attribute :events, Events, :coerce => proc { |v| Events.new(v) }
117
+ attribute :export, Export, :coerce => proc { |v| Export.new(v) }
118
+ attribute :import, Import, :coerce => proc { |v| Import.new(v) }
119
+ attribute :inspect, Inspect, :coerce => proc { |v| Inpsect.new(v) }
120
+ attribute :describe, Describe, :coerce => proc { |v| Describe.new(v) }
121
+ attribute :list, List, :coerce => proc { |v| List.new(v) }
122
+ attribute :promote, Promote, :coerce => proc { |v| Promote.new(v) }
123
+ attribute :validate, Validate, :coerce => proc { |v| Validate.new(v) }
124
124
 
125
125
  # Provide all options for config class (includes global configs)
126
126
  #
@@ -139,25 +139,24 @@ module Sfn
139
139
  def self._options_for(klass, shorts)
140
140
  Smash[
141
141
  ([klass] + klass.ancestors).map do |a|
142
- if(a.ancestors.include?(Bogo::Config) && !a.attributes.empty?)
142
+ if a.ancestors.include?(Bogo::Config) && !a.attributes.empty?
143
143
  a.attributes
144
144
  end
145
- end.compact.reverse.inject(Smash.new){|m, n| m.deep_merge(n)}.map do |name, info|
145
+ end.compact.reverse.inject(Smash.new) { |m, n| m.deep_merge(n) }.map do |name, info|
146
146
  next unless info[:description]
147
147
  short = info[:short_flag]
148
- if(!short.to_s.empty? && shorts.include?(short))
148
+ if !short.to_s.empty? && shorts.include?(short)
149
149
  raise ArgumentError.new "Short flag already in use! (`#{short}` not available for `#{klass}`)"
150
150
  end
151
- unless(short.to_s.empty?)
151
+ unless short.to_s.empty?
152
152
  shorts << short
153
153
  info[:short] = short
154
154
  end
155
155
  info[:long] = name.tr('_', '-')
156
- info[:boolean] = [info[:type]].compact.flatten.all?{|t| BOOLEAN_VALUES.include?(t)}
156
+ info[:boolean] = [info[:type]].compact.flatten.all? { |t| BOOLEAN_VALUES.include?(t) }
157
157
  [name, info]
158
158
  end.compact
159
159
  ]
160
160
  end
161
-
162
161
  end
163
162
  end
@@ -4,13 +4,11 @@ module Sfn
4
4
  class Config
5
5
  # Config command configuration (subclass create to get all the configs)
6
6
  class Conf < Create
7
-
8
7
  attribute(
9
8
  :generate, [TrueClass, FalseClass],
10
9
  :description => 'Generate a basic configuration file',
11
- :short_flag => 'g'
10
+ :short_flag => 'g',
12
11
  )
13
-
14
12
  end
15
13
  end
16
14
  end
@@ -4,30 +4,28 @@ module Sfn
4
4
  class Config
5
5
  # Create command configuration
6
6
  class Create < Update
7
-
8
7
  attribute(
9
8
  :timeout, Integer,
10
- :coerce => proc{|v| v.to_i},
9
+ :coerce => proc { |v| v.to_i },
11
10
  :description => 'Seconds to wait for stack to complete',
12
- :short_flag => 'M'
11
+ :short_flag => 'M',
13
12
  )
14
13
  attribute(
15
14
  :rollback, [TrueClass, FalseClass],
16
15
  :description => 'Rollback stack on failure',
17
- :short_flag => 'O'
16
+ :short_flag => 'O',
18
17
  )
19
18
  attribute(
20
19
  :options, Smash,
21
20
  :description => 'Extra options to apply to the API call',
22
- :short_flag => 'S'
21
+ :short_flag => 'S',
23
22
  )
24
23
  attribute(
25
24
  :notification_topics, String,
26
25
  :multiple => true,
27
26
  :description => 'Notification endpoints for stack events',
28
- :short_flag => 'z'
27
+ :short_flag => 'z',
29
28
  )
30
-
31
29
  end
32
30
  end
33
31
  end
@@ -3,25 +3,23 @@ require 'sfn'
3
3
  module Sfn
4
4
  class Config
5
5
  class Describe < Config
6
-
7
6
  attribute(
8
7
  :resources, [TrueClass, FalseClass],
9
8
  :description => 'Display stack resource list',
10
- :short_flag => 'r'
9
+ :short_flag => 'r',
11
10
  )
12
11
 
13
12
  attribute(
14
13
  :outputs, [TrueClass, FalseClass],
15
14
  :description => 'Display stack outputs',
16
- :short_flag => 'o'
15
+ :short_flag => 'o',
17
16
  )
18
17
 
19
18
  attribute(
20
19
  :tags, [TrueClass, FalseClass],
21
20
  :description => 'Display stack tags',
22
- :short_flag => 't'
21
+ :short_flag => 't',
23
22
  )
24
-
25
23
  end
26
24
  end
27
25
  end
@@ -8,7 +8,7 @@ module Sfn
8
8
  :raw_diff, [TrueClass, FalseClass],
9
9
  :default => false,
10
10
  :description => 'Display raw diff information',
11
- :short_flag => 'w'
11
+ :short_flag => 'w',
12
12
  )
13
13
  end
14
14
  end
@@ -4,31 +4,29 @@ module Sfn
4
4
  class Config
5
5
  # Events command configuration
6
6
  class Events < Config
7
-
8
7
  attribute(
9
8
  :attribute, String,
10
9
  :multiple => true,
11
10
  :description => 'Event attribute to display',
12
- :short_flag => 'a'
11
+ :short_flag => 'a',
13
12
  )
14
13
  attribute(
15
14
  :poll_delay, Integer,
16
15
  :default => 20,
17
16
  :description => 'Seconds to pause between each event poll',
18
- :coerce => lambda{|v| v.to_i},
19
- :short_flag => 'P'
17
+ :coerce => lambda { |v| v.to_i },
18
+ :short_flag => 'P',
20
19
  )
21
20
  attribute(
22
21
  :all_attributes, [TrueClass, FalseClass],
23
22
  :description => 'Display all event attributes',
24
- :short_flag => 'A'
23
+ :short_flag => 'A',
25
24
  )
26
25
  attribute(
27
- :all_events, [TrueClass, FalseClass],
26
+ :all_events, [TrueClass, FalseClass],
28
27
  :description => 'Display all available events',
29
- :short_flag => 'L'
28
+ :short_flag => 'L',
30
29
  )
31
-
32
30
  end
33
31
  end
34
32
  end
@@ -5,25 +5,22 @@ module Sfn
5
5
 
6
6
  # Export command configuration
7
7
  class Export < Config
8
-
9
8
  attribute(
10
9
  :name, String,
11
- :description => 'Export file base name'
10
+ :description => 'Export file base name',
12
11
  )
13
12
  attribute(
14
13
  :path, String,
15
- :description => 'Local path prefix for dump file'
14
+ :description => 'Local path prefix for dump file',
16
15
  )
17
16
  attribute(
18
17
  :bucket, String,
19
- :description => 'Remote storage bucket'
18
+ :description => 'Remote storage bucket',
20
19
  )
21
20
  attribute(
22
21
  :bucket_prefix, String,
23
- :description => 'Remote key prefix within bucket for dump file'
22
+ :description => 'Remote key prefix within bucket for dump file',
24
23
  )
25
-
26
24
  end
27
-
28
25
  end
29
26
  end
@@ -4,33 +4,31 @@ module Sfn
4
4
  class Config
5
5
  # Generate graph
6
6
  class Graph < Validate
7
-
8
7
  attribute(
9
8
  :output_file, String,
10
9
  :description => 'Directory to write graph files',
11
10
  :short_flag => 'O',
12
- :default => File.join(Dir.pwd, 'sfn-graph')
11
+ :default => File.join(Dir.pwd, 'sfn-graph'),
13
12
  )
14
13
 
15
14
  attribute(
16
15
  :output_type, String,
17
16
  :description => 'File output type (Requires graphviz package for non-dot types)',
18
17
  :short_flag => 'e',
19
- :default => 'dot'
18
+ :default => 'dot',
20
19
  )
21
20
 
22
21
  attribute(
23
22
  :graph_style, String,
24
23
  :description => 'Style of graph (`dependency`, `creation`)',
25
- :default => 'creation'
24
+ :default => 'creation',
26
25
  )
27
26
 
28
27
  attribute(
29
28
  :luckymike, [TrueClass, FalseClass],
30
29
  :description => 'Force `dependency` style graph',
31
- :default => false
30
+ :default => false,
32
31
  )
33
-
34
32
  end
35
33
  end
36
34
  end
@@ -5,20 +5,18 @@ module Sfn
5
5
 
6
6
  # Import command configuration
7
7
  class Import < Config
8
-
9
8
  attribute(
10
9
  :path, String,
11
- :description => 'Directory path JSON export files are located'
10
+ :description => 'Directory path JSON export files are located',
12
11
  )
13
12
  attribute(
14
13
  :bucket, String,
15
- :description => 'Remote storage bucket JSON export files are located'
14
+ :description => 'Remote storage bucket JSON export files are located',
16
15
  )
17
16
  attribute(
18
17
  :bucket_prefix, String,
19
- :description => 'Remote key prefix within bucket for dump file'
18
+ :description => 'Remote key prefix within bucket for dump file',
20
19
  )
21
-
22
20
  end
23
21
  end
24
22
  end
@@ -4,7 +4,6 @@ module Sfn
4
4
  class Config
5
5
  # Init command configuration
6
6
  class Init < Config
7
-
8
7
  end
9
8
  end
10
9
  end
@@ -4,45 +4,43 @@ module Sfn
4
4
  class Config
5
5
  # Inspect command configuration
6
6
  class Inspect < Config
7
-
8
7
  attribute(
9
8
  :attribute, String,
10
9
  :multiple => true,
11
10
  :description => 'Dot delimited attribute to view',
12
- :short_flag => 'a'
11
+ :short_flag => 'a',
13
12
  )
14
13
  attribute(
15
14
  :nodes, [TrueClass, FalseClass],
16
15
  :description => 'Locate all instances and display addresses',
17
- :short_flag => 'n'
16
+ :short_flag => 'n',
18
17
  )
19
18
  attribute(
20
19
  :load_balancers, [TrueClass, FalseClass],
21
20
  :description => 'Locate all load balancers, display addresses and server states',
22
- :short_flag => 'l'
21
+ :short_flag => 'l',
23
22
  )
24
23
  attribute(
25
24
  :instance_failure, [TrueClass, FalseClass],
26
25
  :description => 'Display log file error from failed not if possible',
27
- :short_flag => 'N'
26
+ :short_flag => 'N',
28
27
  )
29
28
  attribute(
30
29
  :failure_log_path, String,
31
30
  :description => 'Path to remote log file for display on failure',
32
31
  :default => '/var/log/chef/client.log',
33
- :short_flag => 'f'
32
+ :short_flag => 'f',
34
33
  )
35
34
  attribute(
36
35
  :identity_file, String,
37
36
  :description => 'SSH identity file for authentication',
38
- :short_flag => 'D'
37
+ :short_flag => 'D',
39
38
  )
40
39
  attribute(
41
40
  :ssh_user, String,
42
41
  :description => 'SSH username for inspection connect',
43
- :short_flag => 's'
42
+ :short_flag => 's',
44
43
  )
45
-
46
44
  end
47
45
  end
48
46
  end
@@ -7,22 +7,22 @@ module Sfn
7
7
  attribute(
8
8
  :lint_directory, String,
9
9
  :description => 'Directory containing lint rule sets',
10
- :multiple => true
10
+ :multiple => true,
11
11
  )
12
12
  attribute(
13
13
  :disabled_rule_set, String,
14
14
  :description => 'Disable rule set from being applied',
15
- :multiple => true
15
+ :multiple => true,
16
16
  )
17
17
  attribute(
18
18
  :enabled_rule_set, String,
19
19
  :description => 'Only apply this rule set',
20
- :multiple => true
20
+ :multiple => true,
21
21
  )
22
22
  attribute(
23
23
  :local_rule_sets_only, [TrueClass, FalseClass],
24
24
  :description => 'Only apply rule sets provided by lint directory',
25
- :default => false
25
+ :default => false,
26
26
  )
27
27
  end
28
28
  end