knife-cloudformation 0.1.22 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +56 -2
  4. data/knife-cloudformation.gemspec +4 -7
  5. data/lib/chef/knife/cloudformation_create.rb +105 -245
  6. data/lib/chef/knife/cloudformation_describe.rb +50 -26
  7. data/lib/chef/knife/cloudformation_destroy.rb +17 -18
  8. data/lib/chef/knife/cloudformation_events.rb +48 -14
  9. data/lib/chef/knife/cloudformation_export.rb +117 -34
  10. data/lib/chef/knife/cloudformation_import.rb +124 -18
  11. data/lib/chef/knife/cloudformation_inspect.rb +159 -71
  12. data/lib/chef/knife/cloudformation_list.rb +20 -24
  13. data/lib/chef/knife/cloudformation_promote.rb +40 -0
  14. data/lib/chef/knife/cloudformation_update.rb +132 -15
  15. data/lib/chef/knife/cloudformation_validate.rb +35 -0
  16. data/lib/knife-cloudformation.rb +28 -0
  17. data/lib/knife-cloudformation/cache.rb +213 -35
  18. data/lib/knife-cloudformation/knife.rb +9 -0
  19. data/lib/knife-cloudformation/knife/base.rb +179 -0
  20. data/lib/knife-cloudformation/knife/stack.rb +94 -0
  21. data/lib/knife-cloudformation/knife/template.rb +174 -0
  22. data/lib/knife-cloudformation/monkey_patch.rb +8 -0
  23. data/lib/knife-cloudformation/monkey_patch/stack.rb +195 -0
  24. data/lib/knife-cloudformation/provider.rb +225 -0
  25. data/lib/knife-cloudformation/utils.rb +18 -98
  26. data/lib/knife-cloudformation/utils/animal_strings.rb +28 -0
  27. data/lib/knife-cloudformation/utils/debug.rb +31 -0
  28. data/lib/knife-cloudformation/utils/json.rb +64 -0
  29. data/lib/knife-cloudformation/utils/object_storage.rb +28 -0
  30. data/lib/knife-cloudformation/utils/output.rb +79 -0
  31. data/lib/knife-cloudformation/utils/path_selector.rb +99 -0
  32. data/lib/knife-cloudformation/utils/ssher.rb +29 -0
  33. data/lib/knife-cloudformation/utils/stack_exporter.rb +271 -0
  34. data/lib/knife-cloudformation/utils/stack_parameter_scrubber.rb +35 -0
  35. data/lib/knife-cloudformation/utils/stack_parameter_validator.rb +124 -0
  36. data/lib/knife-cloudformation/version.rb +2 -4
  37. metadata +47 -94
  38. data/Gemfile +0 -3
  39. data/Gemfile.lock +0 -90
  40. data/knife-cloudformation-0.1.20.gem +0 -0
  41. data/lib/knife-cloudformation/aws_commons.rb +0 -267
  42. data/lib/knife-cloudformation/aws_commons/stack.rb +0 -435
  43. data/lib/knife-cloudformation/aws_commons/stack_parameter_validator.rb +0 -79
  44. data/lib/knife-cloudformation/cloudformation_base.rb +0 -168
  45. data/lib/knife-cloudformation/export.rb +0 -174
@@ -0,0 +1,35 @@
1
+ require 'knife-cloudformation'
2
+
3
+ module KnifeCloudformation
4
+ module Utils
5
+ # Helper for scrubbing stack parameters
6
+ class StackParameterScrubber
7
+
8
+ class << self
9
+
10
+ # Validate attributes within Parameter blocks
11
+ ALLOWED_PARAMETER_ATTRIBUTES = %w(
12
+ Type Default NoEcho AllowedValues AllowedPattern
13
+ MaxLength MinLength MaxValue MinValue Description
14
+ ConstraintDescription
15
+ )
16
+
17
+ # Clean the parameters of the template
18
+ #
19
+ # @param template [Hash]
20
+ # @return [Hash] template
21
+ def scrub!(template)
22
+ parameters = template.fetch('Parameters', {})
23
+ parameters.each do |name, options|
24
+ options.delete_if do |attribute, value|
25
+ !ALLOWED_PARAMETER_ATTRIBUTES.include?(attribute)
26
+ end
27
+ end
28
+ template['Parameters'] = parameters
29
+ template
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,124 @@
1
+ require 'knife-cloudformation'
2
+
3
+ module KnifeCloudformation
4
+ module Utils
5
+
6
+ # Helper utility for validating stack parameters
7
+ class StackParameterValidator
8
+ class << self
9
+
10
+ include KnifeCloudformation::Utils::AnimalStrings
11
+
12
+ # Validate a parameters
13
+ #
14
+ # @param value [Object] value for parameter
15
+ # @param parameter_definition [Hash]
16
+ # @option parameter_definition [Array<String>] 'AllowedValues'
17
+ # @option parameter_definition [String] 'AllowedPattern'
18
+ # @option parameter_definition [String, Integer] 'MaxLength'
19
+ # @option parameter_definition [String, Integer] 'MinLength'
20
+ # @option parameter_definition [String, Integer] 'MaxValue'
21
+ # @option parameter_definition [String, Integer] 'MinValue'
22
+ # @return [TrueClass, Array<String>] true if valid. array of string errors if invalid
23
+ def validate(value, parameter_definition)
24
+ return [[:blank, 'Value cannot be blank']] if value.to_s.strip.empty?
25
+ result = %w(AllowedValues AllowedPattern MaxLength MinLength MaxValue MinValue).map do |key|
26
+ if(parameter_definition[key])
27
+ res = self.send(snake(key), value, parameter_definition)
28
+ res == true ? true : [snake(key), res]
29
+ else
30
+ true
31
+ end
32
+ end
33
+ result.delete_if{|x| x == true}
34
+ result.empty? ? true : result
35
+ end
36
+
37
+ # Parameter is within allowed values
38
+ #
39
+ # @param value [String]
40
+ # @param pdef [Hash] parameter definition
41
+ # @option pdef [Array<String>] 'AllowedValues'
42
+ # @return [TrueClass, String]
43
+ def allowed_values(value, pdef)
44
+ if(pdef['AllowedValues'].include?(value))
45
+ true
46
+ else
47
+ "Not an allowed value: #{pdef['AllowedValues'].join(', ')}"
48
+ end
49
+ end
50
+
51
+ # Parameter matches allowed pattern
52
+ #
53
+ # @param value [String]
54
+ # @param pdef [Hash] parameter definition
55
+ # @option pdef [String] 'AllowedPattern'
56
+ # @return [TrueClass, String]
57
+ def allowed_pattern(value, pdef)
58
+ if(value.match(/#{pdef['AllowedPattern']}/))
59
+ true
60
+ else
61
+ "Not a valid pattern. Must match: #{pdef['AllowedPattern']}"
62
+ end
63
+ end
64
+
65
+ # Parameter length is less than or equal to max length
66
+ #
67
+ # @param value [String, Integer]
68
+ # @param pdef [Hash] parameter definition
69
+ # @option pdef [String] 'MaxLength'
70
+ # @return [TrueClass, String]
71
+ def max_length(value, pdef)
72
+ if(value.length <= pdef['MaxLength'].to_i)
73
+ true
74
+ else
75
+ "Value must not exceed #{pdef['MaxLength']} characters"
76
+ end
77
+ end
78
+
79
+ # Parameter length is greater than or equal to min length
80
+ #
81
+ # @param value [String]
82
+ # @param pdef [Hash] parameter definition
83
+ # @option pdef [String] 'MinLength'
84
+ # @return [TrueClass, String]
85
+ def min_length(value, pdef)
86
+ if(value.length >= pdef['MinLength'].to_i)
87
+ true
88
+ else
89
+ "Value must be at least #{pdef['MinLength']} characters"
90
+ end
91
+ end
92
+
93
+ # Parameter value is less than or equal to max value
94
+ #
95
+ # @param value [String]
96
+ # @param pdef [Hash] parameter definition
97
+ # @option pdef [String] 'MaxValue'
98
+ # @return [TrueClass, String]
99
+ def max_value(value, pdef)
100
+ if(value.to_i <= pdef['MaxValue'].to_i)
101
+ true
102
+ else
103
+ "Value must not be greater than #{pdef['MaxValue']}"
104
+ end
105
+ end
106
+
107
+ # Parameter value is greater than or equal to min value
108
+ #
109
+ # @param value [String]
110
+ # @param pdef [Hash] parameter definition
111
+ # @option pdef [String] 'MinValue'
112
+ # @return [TrueClass, String]
113
+ def min_value(value, pdef)
114
+ if(value.to_i >= pdef['MinValue'].to_i)
115
+ true
116
+ else
117
+ "Value must not be less than #{pdef['MinValue']}"
118
+ end
119
+ end
120
+
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,6 +1,4 @@
1
1
  module KnifeCloudformation
2
- class Version < Gem::Version
3
- end
4
-
5
- VERSION = Version.new('0.1.22')
2
+ # Current library version
3
+ VERSION = Gem::Version.new('0.2.0')
6
4
  end
metadata CHANGED
@@ -1,181 +1,134 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cloudformation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Roberts
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: chef
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: fog
28
+ name: miasma
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.17'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.17'
46
- - !ruby/object:Gem::Dependency
47
- name: unf
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
31
+ - - ">="
52
32
  - !ruby/object:Gem::Version
53
33
  version: '0'
54
34
  type: :runtime
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
- - - ! '>='
38
+ - - ">="
60
39
  - !ruby/object:Gem::Version
61
40
  version: '0'
62
41
  - !ruby/object:Gem::Dependency
63
- name: net-sftp
42
+ name: net-ssh
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ! '>='
45
+ - - ">="
68
46
  - !ruby/object:Gem::Version
69
47
  version: '0'
70
48
  type: :runtime
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ! '>='
52
+ - - ">="
76
53
  - !ruby/object:Gem::Version
77
54
  version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: sparkle_formation
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: 0.1.2
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 0.1.2
94
- - !ruby/object:Gem::Dependency
95
- name: redis-objects
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
58
  requirements:
99
- - - ! '>='
59
+ - - "~>"
100
60
  - !ruby/object:Gem::Version
101
- version: '0'
61
+ version: 0.2.0
102
62
  type: :runtime
103
63
  prerelease: false
104
64
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: attribute_struct
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
65
  requirements:
115
- - - ~>
66
+ - - "~>"
116
67
  - !ruby/object:Gem::Version
117
- version: 0.1.8
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 0.1.8
68
+ version: 0.2.0
126
69
  description: Knife tooling for Cloud Formation
127
70
  email: chrisroberts.code@gmail.com
128
71
  executables: []
129
72
  extensions: []
130
73
  extra_rdoc_files: []
131
74
  files:
132
- - lib/chef/knife/cloudformation_events.rb
133
- - lib/chef/knife/cloudformation_destroy.rb
75
+ - CHANGELOG.md
76
+ - README.md
77
+ - knife-cloudformation.gemspec
78
+ - lib/chef/knife/cloudformation_create.rb
134
79
  - lib/chef/knife/cloudformation_describe.rb
80
+ - lib/chef/knife/cloudformation_destroy.rb
81
+ - lib/chef/knife/cloudformation_events.rb
135
82
  - lib/chef/knife/cloudformation_export.rb
83
+ - lib/chef/knife/cloudformation_import.rb
84
+ - lib/chef/knife/cloudformation_inspect.rb
136
85
  - lib/chef/knife/cloudformation_list.rb
137
- - lib/chef/knife/cloudformation_create.rb
86
+ - lib/chef/knife/cloudformation_promote.rb
138
87
  - lib/chef/knife/cloudformation_update.rb
139
- - lib/chef/knife/cloudformation_inspect.rb
140
- - lib/chef/knife/cloudformation_import.rb
88
+ - lib/chef/knife/cloudformation_validate.rb
141
89
  - lib/knife-cloudformation.rb
142
- - lib/knife-cloudformation/cloudformation_base.rb
143
- - lib/knife-cloudformation/version.rb
144
- - lib/knife-cloudformation/export.rb
145
- - lib/knife-cloudformation/aws_commons.rb
146
90
  - lib/knife-cloudformation/cache.rb
91
+ - lib/knife-cloudformation/knife.rb
92
+ - lib/knife-cloudformation/knife/base.rb
93
+ - lib/knife-cloudformation/knife/stack.rb
94
+ - lib/knife-cloudformation/knife/template.rb
95
+ - lib/knife-cloudformation/monkey_patch.rb
96
+ - lib/knife-cloudformation/monkey_patch/stack.rb
97
+ - lib/knife-cloudformation/provider.rb
147
98
  - lib/knife-cloudformation/utils.rb
148
- - lib/knife-cloudformation/aws_commons/stack_parameter_validator.rb
149
- - lib/knife-cloudformation/aws_commons/stack.rb
150
- - Gemfile
151
- - README.md
152
- - knife-cloudformation.gemspec
153
- - knife-cloudformation-0.1.20.gem
154
- - CHANGELOG.md
155
- - Gemfile.lock
99
+ - lib/knife-cloudformation/utils/animal_strings.rb
100
+ - lib/knife-cloudformation/utils/debug.rb
101
+ - lib/knife-cloudformation/utils/json.rb
102
+ - lib/knife-cloudformation/utils/object_storage.rb
103
+ - lib/knife-cloudformation/utils/output.rb
104
+ - lib/knife-cloudformation/utils/path_selector.rb
105
+ - lib/knife-cloudformation/utils/ssher.rb
106
+ - lib/knife-cloudformation/utils/stack_exporter.rb
107
+ - lib/knife-cloudformation/utils/stack_parameter_scrubber.rb
108
+ - lib/knife-cloudformation/utils/stack_parameter_validator.rb
109
+ - lib/knife-cloudformation/version.rb
156
110
  homepage: http://github.com/heavywater/knife-cloudformation
157
111
  licenses: []
112
+ metadata: {}
158
113
  post_install_message:
159
114
  rdoc_options: []
160
115
  require_paths:
161
116
  - lib
162
117
  required_ruby_version: !ruby/object:Gem::Requirement
163
- none: false
164
118
  requirements:
165
- - - ! '>='
119
+ - - ">="
166
120
  - !ruby/object:Gem::Version
167
121
  version: '0'
168
122
  required_rubygems_version: !ruby/object:Gem::Requirement
169
- none: false
170
123
  requirements:
171
- - - ! '>='
124
+ - - ">="
172
125
  - !ruby/object:Gem::Version
173
126
  version: '0'
174
127
  requirements: []
175
128
  rubyforge_project:
176
- rubygems_version: 1.8.24
129
+ rubygems_version: 2.2.2
177
130
  signing_key:
178
- specification_version: 3
131
+ specification_version: 4
179
132
  summary: Knife tooling for Cloud Formation
180
133
  test_files: []
181
134
  has_rdoc:
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,90 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- knife-cloudformation (0.1.9)
5
- attribute_struct (~> 0.1.6)
6
- chef
7
- fog (~> 1.15)
8
- net-sftp
9
- redis-objects
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- attribute_struct (0.1.6)
15
- hashie (>= 2.0.0)
16
- builder (3.2.2)
17
- chef (11.6.0)
18
- erubis
19
- highline (>= 1.6.9)
20
- json (>= 1.4.4, <= 1.7.7)
21
- mixlib-authentication (>= 1.3.0)
22
- mixlib-cli (~> 1.3.0)
23
- mixlib-config (>= 1.1.2)
24
- mixlib-log (>= 1.3.0)
25
- mixlib-shellout
26
- net-ssh (~> 2.6)
27
- net-ssh-multi (~> 1.1.0)
28
- ohai (>= 0.6.0)
29
- rest-client (>= 1.0.4, < 1.7.0)
30
- yajl-ruby (~> 1.1)
31
- erubis (2.7.0)
32
- excon (0.25.3)
33
- fog (1.15.0)
34
- builder
35
- excon (~> 0.25.0)
36
- formatador (~> 0.2.0)
37
- mime-types
38
- multi_json (~> 1.0)
39
- net-scp (~> 1.1)
40
- net-ssh (>= 2.1.3)
41
- nokogiri (~> 1.5)
42
- ruby-hmac
43
- formatador (0.2.4)
44
- hashie (2.0.5)
45
- highline (1.6.19)
46
- ipaddress (0.8.0)
47
- json (1.7.7)
48
- mime-types (1.25)
49
- mini_portile (0.5.1)
50
- mixlib-authentication (1.3.0)
51
- mixlib-log
52
- mixlib-cli (1.3.0)
53
- mixlib-config (2.0.0)
54
- mixlib-log (1.6.0)
55
- mixlib-shellout (1.2.0)
56
- multi_json (1.8.0)
57
- net-scp (1.1.2)
58
- net-ssh (>= 2.6.5)
59
- net-sftp (2.1.2)
60
- net-ssh (>= 2.6.5)
61
- net-ssh (2.7.0)
62
- net-ssh-gateway (1.2.0)
63
- net-ssh (>= 2.6.5)
64
- net-ssh-multi (1.1)
65
- net-ssh (>= 2.1.4)
66
- net-ssh-gateway (>= 0.99.0)
67
- nokogiri (1.6.0)
68
- mini_portile (~> 0.5.0)
69
- ohai (6.18.0)
70
- ipaddress
71
- mixlib-cli
72
- mixlib-config
73
- mixlib-log
74
- mixlib-shellout
75
- systemu
76
- yajl-ruby
77
- redis (3.0.5)
78
- redis-objects (0.7.0)
79
- redis (>= 3.0.2)
80
- rest-client (1.6.7)
81
- mime-types (>= 1.16)
82
- ruby-hmac (0.4.0)
83
- systemu (2.5.2)
84
- yajl-ruby (1.1.0)
85
-
86
- PLATFORMS
87
- ruby
88
-
89
- DEPENDENCIES
90
- knife-cloudformation!