kumogata 0.2.14 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTRiNjQ5NzgzNjlhMDIzZDI2NzE4NTA0OWE2NjU4MjdlODBhNDkxMA==
4
+ ZmI3MThkOWFjMTgxNDA2YzI3ZjQ5NzU1NjZkMmUyNmFjOWI3MWMyOQ==
5
5
  data.tar.gz: !binary |-
6
- ZWM4Y2MxOWU0ZjMxMDkzMTQ3OGY2MTcyNmRkNzJjODA5MDgzYjNiYQ==
6
+ NTNhYjcwN2YxYzUzNzM1OWVlYzBlOWM3NjUxOThkNzg0M2I5ZTMwZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTdkNmUzNGIxNzBiNDA0N2NjZDcxODkzY2I0NzZmYWQ1NmM2Zjc2MTUzN2Uy
10
- ZWEwMzA0NjFjODg3MzdmZjc0ZWYyYTFjNDUzNWM4NjAxYzE3ZTU2YTc2MzBl
11
- MTYwOTg1NTUxZjdmMjQ1ZTE2YWI5Y2IyZThhYTc1Y2MzZGM1Y2I=
9
+ YjIyZTkwYmNhZDFhMDJhYTdiMmIxMjIwZjcwYzZmYzgxYmE2NWYxYmE2NmYy
10
+ YmExNmRjMWE1NjhiMzEwNjFlOTU4MjQ5OTJkN2NkNTE4ZmJjNjI5N2FkM2Yx
11
+ MjFjZDRiNWRjNDhlNTZhZGE3YzRiMTdkODdmNTM4ODhiZDEzNWM=
12
12
  data.tar.gz: !binary |-
13
- YzdjMGE2NDEwOThiYjA2MWZkMjJlMDkxNjNiYTQxYTcxY2QzYTBmNTk3Nzg4
14
- MWRlZmE5MGQzYzFiMGQwOGRiNTBkNTU5ZGEyM2JiMjNmNGEzNDIxNDQ1MjY3
15
- MzhjMTY3MmEwOWQ0NGM5MmI2ZWUwN2ZhYjFhODdlYzc1NjhjMjQ=
13
+ YmQwMTlmNGU5YjAwNGI1ZWJiNGIzZjgyMWNlOWViMTgzMmRhZDY1NjNmYjVj
14
+ ZjdiN2Q5NGY3ODMzYTMxYjEwMGU4M2Y4ZWM0MDYwMzNmNWVmN2Q4MjMwZWQx
15
+ NzQwYmE1NWJhNmVmYzgxOWI2MDZjYWQ4MzI2Y2NlYjdhZGMwOGE=
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403072016)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403072016)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403072151)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403072151)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
@@ -97,6 +97,12 @@ Options:
97
97
  --debug
98
98
  ```
99
99
 
100
+ ### KUMOGATA_OPTIONS
101
+
102
+ `KUMOGATA_OPTIONS` variable specifies default options.
103
+
104
+ e.g. `KUMOGATA_OPTIONS='-e Password'`
105
+
100
106
  ### Create resources
101
107
 
102
108
  $ kumogata create template.rb
@@ -14,6 +14,7 @@ require 'open-uri'
14
14
  require 'optparse'
15
15
  require 'singleton'
16
16
  require 'stringio'
17
+ require 'strscan'
17
18
  require 'uuidtools'
18
19
 
19
20
  require 'kumogata/argument_parser'
@@ -5,7 +5,6 @@ module Kumogata
5
5
  end
6
6
 
7
7
  class Kumogata::ArgumentParser
8
-
9
8
  DEFAULT_OPTIONS = {
10
9
  :replace_underscore => true,
11
10
  :delete_stack => true,
@@ -72,6 +71,10 @@ class Kumogata::ArgumentParser
72
71
  arguments = nil
73
72
  options = {}
74
73
 
74
+ if ENV['KUMOGATA_OPTIONS']
75
+ ARGV.concat(scan_args(ENV['KUMOGATA_OPTIONS']))
76
+ end
77
+
75
78
  ARGV.options do |opt|
76
79
  update_usage(opt)
77
80
 
@@ -196,4 +199,31 @@ class Kumogata::ArgumentParser
196
199
  options.parameters[Kumogata::ENCRYPTION_PASSWORD] = passwd.encode64
197
200
  end
198
201
  end
202
+
203
+ def scan_args(str)
204
+ args = []
205
+ ss = StringScanner.new(str)
206
+ buf = ''
207
+
208
+ until ss.eos?
209
+ if ss.scan(/\s+/)
210
+ unless buf.empty?
211
+ args << buf
212
+ buf = ''
213
+ end
214
+ elsif (tok = ss.scan(/'[^']*'/))
215
+ buf << tok.gsub(/'([^']*)'/) { $1 }
216
+ elsif (tok = ss.scan(/"[^"]*"/))
217
+ buf << tok.gsub(/"([^"]*)"/) { $1 }
218
+ elsif (tok = ss.scan(/[^\s'"]+/))
219
+ buf << tok
220
+ else
221
+ buf << ss.getch
222
+ end
223
+ end
224
+
225
+ args << buf unless buf.empty?
226
+
227
+ return args
228
+ end
199
229
  end
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.14'
2
+ VERSION = '0.2.15'
3
3
  end
@@ -21,7 +21,7 @@ end
21
21
  EOS
22
22
 
23
23
  run_client(:validate, :template => template) do |client, cf|
24
- json = eval_template(template).to_json
24
+ json = eval_template(template, :add_encryption_password_for_validation => true).to_json
25
25
 
26
26
  cf.should_receive(:validate_template).with(json) {
27
27
  {}
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  expect {
54
54
  run_client(:validate, :template => template) do |client, cf|
55
- json = eval_template(template).to_json
55
+ json = eval_template(template, :add_encryption_password_for_validation => true).to_json
56
56
 
57
57
  cf.should_receive(:validate_template).with(json) {
58
58
  {
@@ -88,9 +88,11 @@ end
88
88
  EOS
89
89
 
90
90
  run_client(:validate, :template => template, :template_ext => '.template') do |client, cf|
91
- json = JSON.parse(template).to_json
91
+ template = JSON.parse(template)
92
+ add_encryption_password_for_validation(template)
93
+ json = template.to_json
92
94
 
93
- cf.should_receive(:validate_template).with(json) {
95
+ cf.should_receive(:validate_template) {
94
96
  {}
95
97
  }
96
98
  end
@@ -121,7 +123,9 @@ end
121
123
 
122
124
  expect {
123
125
  run_client(:validate, :template => template, :template_ext => '.template') do |client, cf|
124
- json = JSON.parse(template).to_json
126
+ template = JSON.parse(template)
127
+ add_encryption_password_for_validation(template)
128
+ json = template.to_json
125
129
 
126
130
  cf.should_receive(:validate_template).with(json) {
127
131
  {
@@ -57,6 +57,10 @@ def eval_template(template, options = {})
57
57
  add_encryption_password(template)
58
58
  end
59
59
 
60
+ if options[:add_encryption_password_for_validation]
61
+ add_encryption_password_for_validation(template)
62
+ end
63
+
60
64
  return template
61
65
  end
62
66
 
@@ -75,6 +79,15 @@ def add_encryption_password(template)
75
79
  }
76
80
  end
77
81
 
82
+ def add_encryption_password_for_validation(template)
83
+ template['Parameters'] ||= {}
84
+
85
+ template['Parameters'][Kumogata::ENCRYPTION_PASSWORD] = {
86
+ 'Type' => 'String',
87
+ 'Default' => "(#{Kumogata::ENCRYPTION_PASSWORD})",
88
+ }
89
+ end
90
+
78
91
  def make_double(name)
79
92
  obj = double(name)
80
93
  yield(obj)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara