cloudformation-ruby-dsl 1.2.4 → 1.2.5

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: b96d9566c8f7eb64af7c88c4d809d6c6b6cd79ac
4
- data.tar.gz: d43e2ce163a5047f8aeecd15cf936bdf422bfff8
3
+ metadata.gz: 0c0ff566160bc6cd49546a86129814e4f7456149
4
+ data.tar.gz: f2b3e70794460d1214c1c336762f2d4e238b3247
5
5
  SHA512:
6
- metadata.gz: 457204dfb740fbccc51371e4017006bab15e9b03e3ced9bace517850f0494008dc653171b60626c02addc13fe191c25c5601cd466a469c16d0381c4ae12a67e6
7
- data.tar.gz: 12a0a10691d43c267fb2172a9a0ba7b703f4f16ecebd95f856a1028ac4b5924def354dae0f10d1ea60d6e27371a33e31b035fd99244b37142ea294b978439c53
6
+ metadata.gz: 87f36d247b8db1ec5fcbe951f35a84a71d127883185788fc29676d0be65bac0e5f05648ad81f9d4c0f602a0b52b00d52c4c4b958c837f0b0069b1ac42eff1c9b
7
+ data.tar.gz: 63de25f85683010039ec5215b41fd05a2e0924b6b69582d691a512c152aff19e98f1f6bbe8950d4580fc68c0eafafc29c03e170c4ccca1d5b76a644a12a17cea
@@ -0,0 +1,30 @@
1
+ ## Description
2
+ Describe the objective of this PR.
3
+
4
+ ## Steps to Test or Reproduce
5
+ Outline the steps to test or reproduce the PR here.
6
+ ```
7
+ Code that reproduces the behaviour of the PR/to be fixed by the PR
8
+ ```
9
+ ### Environment
10
+ Describe the environment the bug or feature can be observed in. This may include platform, ruby version, DSL info, etc.
11
+
12
+ ## Deploy Notes
13
+ If the change affects the way in which the gem is released, or requires a bump in version, note this here.
14
+
15
+ ## Related Issues and PRs
16
+
17
+ ### Issues
18
+ - [issue_link]()
19
+
20
+ ### PRs
21
+ - [pr1]()
22
+ - [pr2]()
23
+
24
+ ## Todos
25
+ - [x] Pull Request
26
+ - [ ] Tests
27
+ - [ ] Documentation
28
+
29
+ ## Request to Review
30
+ @jonaf/@temujin9
@@ -78,32 +78,26 @@ end
78
78
 
79
79
  # Parse command-line arguments and return the parameters and region
80
80
  def parse_args
81
- args = {
82
- :stack_name => nil,
83
- :parameters => {},
84
- :interactive => false,
85
- :region => default_region,
86
- :profile => nil,
87
- :nopretty => false,
88
- }
81
+ stack_name = nil
82
+ parameters = {}
83
+ region = default_region
84
+ profile = nil
85
+ nopretty = false
89
86
  ARGV.slice_before(/^--/).each do |name, value|
90
87
  case name
91
88
  when '--stack-name'
92
- args[:stack_name] = value
89
+ stack_name = value
93
90
  when '--parameters'
94
- args[:parameters] = Hash[value.split(/;/).map { |pair| pair.split(/=/, 2) }] #/# fix for syntax highlighting
95
- when '--interactive'
96
- args[:interactive] = true
91
+ parameters = Hash[value.split(/;/).map { |pair| pair.split(/=/, 2) }] #/# fix for syntax highlighting
97
92
  when '--region'
98
- args[:region] = value
93
+ region = value
99
94
  when '--profile'
100
- args[:profile] = value
95
+ profile = value
101
96
  when '--nopretty'
102
- args[:nopretty] = true
97
+ nopretty = true
103
98
  end
104
99
  end
105
-
106
- args
100
+ [stack_name, parameters, region, profile, nopretty]
107
101
  end
108
102
 
109
103
  def validate_action(action)
@@ -300,16 +294,13 @@ def cfn(template)
300
294
  template_body: template_string,
301
295
  parameters: template.parameters.map { |k,v| {parameter_key: k, parameter_value: v}}.to_a,
302
296
  tags: cfn_tags.map { |k,v| {"key" => k.to_s, "value" => v} }.to_a,
303
- capabilities: ["CAPABILITY_NAMED_IAM"],
297
+ capabilities: ["CAPABILITY_IAM"],
304
298
  }
305
299
 
306
300
  # fill in options from the command line
307
301
  extra_options = parse_arg_array_as_hash(options)
308
302
  create_stack_opts = extra_options.merge(create_stack_opts)
309
303
 
310
- # remove custom options
311
- create_stack_opts.delete(:interactive)
312
-
313
304
  # create stack
314
305
  create_result = cfn_client.create_stack(create_stack_opts)
315
306
  if create_result.successful?
@@ -495,16 +486,13 @@ def cfn(template)
495
486
  template_body: template_string,
496
487
  parameters: template.parameters.map { |k,v| {parameter_key: k, parameter_value: v}}.to_a,
497
488
  tags: cfn_tags.map { |k,v| {"key" => k.to_s, "value" => v.to_s} }.to_a,
498
- capabilities: ["CAPABILITY_NAMED_IAM"],
489
+ capabilities: ["CAPABILITY_IAM"],
499
490
  }
500
491
 
501
492
  # fill in options from the command line
502
493
  extra_options = parse_arg_array_as_hash(options)
503
494
  update_stack_opts = extra_options.merge(update_stack_opts)
504
495
 
505
- # remove custom options
506
- update_stack_opts.delete(:interactive)
507
-
508
496
  # update the stack
509
497
  update_result = cfn_client.update_stack(update_stack_opts)
510
498
  if update_result.successful?
@@ -579,6 +567,6 @@ end
579
567
 
580
568
  # Main entry point
581
569
  def template(&block)
582
- options = parse_args
583
- raw_template(options, &block)
570
+ stack_name, parameters, aws_region, aws_profile, nopretty = parse_args
571
+ raw_template(parameters, stack_name, aws_region, aws_profile, nopretty, &block)
584
572
  end
@@ -44,8 +44,8 @@ end
44
44
  ############################# CloudFormation DSL
45
45
 
46
46
  # Main entry point
47
- def raw_template(options, &block)
48
- TemplateDSL.new(options, &block)
47
+ def raw_template(parameters = {}, stack_name = nil, aws_region = default_region, aws_profile = nil, nopretty = false, &block)
48
+ TemplateDSL.new(parameters, stack_name, aws_region, aws_profile, nopretty, &block)
49
49
  end
50
50
 
51
51
  def default_region
@@ -54,20 +54,14 @@ end
54
54
 
55
55
  # Core interpreter for the DSL
56
56
  class TemplateDSL < JsonObjectDSL
57
- attr_reader :parameters,
58
- :parameter_cli,
59
- :aws_region,
60
- :nopretty,
61
- :stack_name,
62
- :aws_profile
63
-
64
- def initialize(options)
65
- @parameters = options[:parameters]
66
- @interactive = options[:interactive]
67
- @stack_name = options[:stack_name]
68
- @aws_region = options[:region]
69
- @aws_profile = options[:profile]
70
- @nopretty = options[:nopretty]
57
+ attr_reader :parameters, :aws_region, :nopretty, :stack_name, :aws_profile
58
+
59
+ def initialize(parameters = {}, stack_name = nil, aws_region = default_region, aws_profile = nil, nopretty = false)
60
+ @parameters = parameters
61
+ @stack_name = stack_name
62
+ @aws_region = aws_region
63
+ @aws_profile = aws_profile
64
+ @nopretty = nopretty
71
65
  super()
72
66
  end
73
67
 
@@ -77,12 +71,7 @@ class TemplateDSL < JsonObjectDSL
77
71
 
78
72
  def parameter(name, options)
79
73
  default(:Parameters, {})[name] = options
80
-
81
- if @interactive
82
- @parameters[name] ||= _get_parameter_from_cli(name, options)
83
- else
84
- @parameters[name] ||= options[:Default]
85
- end
74
+ @parameters[name] ||= options[:Default]
86
75
  end
87
76
 
88
77
  # Find parameters where the specified attribute is true then remove the attribute from the cfn template.
@@ -173,73 +162,6 @@ class TemplateDSL < JsonObjectDSL
173
162
  { :'Fn::FindInMap' => [ map, key, name ] }
174
163
  end
175
164
  end
176
-
177
- private
178
- def _get_parameter_from_cli(name, options)
179
- # basic request
180
- param_request = "Parameter '#{name}' (#{options[:Type]})"
181
-
182
- # add description to request
183
- if options.has_key?(:Description)
184
- param_request += "\nDescription: #{options[:Description]}"
185
- end
186
-
187
- # add validation to the request
188
-
189
- # allowed pattern
190
- if options.has_key?(:AllowedPattern)
191
- param_request += "\nAllowed Pattern: /#{options[:AllowedPattern]}/"
192
- end
193
-
194
- # allowed values
195
- if options.has_key?(:AllowedValues)
196
- param_request += "\nAllowed Values: #{options[:AllowedValues].join(', ')}"
197
- end
198
-
199
- # min/max length
200
- if options.has_key?(:MinLength) or options.has_key?(:MaxLength)
201
- min_length = "-infinity"
202
- max_length = "+infinity"
203
- if options.has_key?(:MinLength)
204
- min_length = options[:MinLength]
205
- end
206
- if options.has_key?(:MaxLength)
207
- max_length = options[:MaxLength]
208
- end
209
- param_request += "\nValid Length: #{min_length} < string < #{max_length}"
210
- end
211
-
212
- # min/max value
213
- if options.has_key?(:MinValue) or options.has_key?(:MaxValue)
214
- min_value = "-infinity"
215
- max_value = "+infinity"
216
- if options.has_key?(:MinValue)
217
- min_value = options[:MinValue]
218
- end
219
- if options.has_key?(:MaxValue)
220
- max_value = options[:MaxValue]
221
- end
222
- param_request += "\nValid Number: #{min_value} < number < #{max_value}"
223
- end
224
-
225
- # add default to request
226
- if options.has_key?(:Default) and !options[:Default].nil?
227
- param_request += "\nLeave value empty for default: #{options[:Default]}"
228
- end
229
-
230
- param_request += "\nValue: "
231
-
232
- # request the param
233
- $stdout.puts "===================="
234
- $stdout.print param_request
235
- input = $stdin.gets.chomp
236
-
237
- if input.nil? or input.empty?
238
- options[:Default]
239
- else
240
- input
241
- end
242
- end
243
165
  end
244
166
 
245
167
  def base64(value) { :'Fn::Base64' => value } end
@@ -250,8 +172,6 @@ def get_att(resource, attribute) { :'Fn::GetAtt' => [ resource, attribute ] } en
250
172
 
251
173
  def get_azs(region = '') { :'Fn::GetAZs' => region } end
252
174
 
253
- def import_value(value) { :'Fn::ImportValue' => value } end
254
-
255
175
  def join(delim, *list)
256
176
  case list.length
257
177
  when 0 then ''
@@ -15,7 +15,7 @@
15
15
  module Cfn
16
16
  module Ruby
17
17
  module Dsl
18
- VERSION = "1.2.4"
18
+ VERSION = "1.2.5"
19
19
  end
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudformation-ruby-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Smith
@@ -15,132 +15,132 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2016-10-12 00:00:00.000000000 Z
18
+ date: 2016-10-18 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: detabulator
22
22
  requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  type: :runtime
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: json
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: aws-sdk
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.5.1
69
69
  type: :runtime
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.5.1
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: diffy
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: highline
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rake
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: rspec
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: pry
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  description: Ruby DSL library that provides a wrapper around the CloudFormation.
@@ -158,10 +158,11 @@ executables:
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
- - .gitignore
161
+ - ".gitignore"
162
162
  - Gemfile
163
163
  - LICENSE
164
164
  - OWNERS
165
+ - PULL_REQUEST_TEMPLATE.md
165
166
  - README.md
166
167
  - Rakefile
167
168
  - bin/cfntemplate-to-ruby
@@ -199,17 +200,17 @@ require_paths:
199
200
  - bin
200
201
  required_ruby_version: !ruby/object:Gem::Requirement
201
202
  requirements:
202
- - - '>='
203
+ - - ">="
203
204
  - !ruby/object:Gem::Version
204
205
  version: '0'
205
206
  required_rubygems_version: !ruby/object:Gem::Requirement
206
207
  requirements:
207
- - - '>='
208
+ - - ">="
208
209
  - !ruby/object:Gem::Version
209
210
  version: '0'
210
211
  requirements: []
211
212
  rubyforge_project:
212
- rubygems_version: 2.0.14
213
+ rubygems_version: 2.5.1
213
214
  signing_key:
214
215
  specification_version: 4
215
216
  summary: Ruby DSL library that provides a wrapper around the CloudFormation. Written