kumogata 0.2.19 → 0.3.0

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
- OTIzZjQ1YzM3MGFkNzQ0YmRiMjYyMDFlMjVmYjEwMjgzNTliZDU2Mg==
4
+ MDJiY2RhMjljMGZiZDMzOGM3YTdlZjkxYmFkNTk3YjIwNDc3NmJmOQ==
5
5
  data.tar.gz: !binary |-
6
- ZTA2ZjU5YTc1YTRjMjE4ZGY0NWUzNzM1ZTBhNjljMDBjNmY4NzhlYQ==
6
+ YjU3NzFmM2I0MTIzMWQ3MjQ3N2E4YjcyODBmMTg5YzJhOGU4OWZlZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmU2OWY3YzBjM2QwYjE1ZjQ0OGE3ZGE0ZmYwOGQ2MDdhNzIxOWM5MGE3YjMx
10
- YjgwYjRhMmY0Y2MzMWI4OTFiMmFmMmQxZjRmNzQxNmFmNTZjNGEwZDllZmNh
11
- MDU3ZWVmMmYyZDkzOTEzYzEzZDk4OGJjOTQxOWZjMTVhYmRlOGU=
9
+ NDllOGZhMzQ0ZjRlODVlMmI3MTVjZGU1NzhhMDkxNjJmM2EzNmRiZTk4Zjk4
10
+ ODQxZWU5Y2NmZTEyMmI2MzQzNjhiMGM1MGM4NGI3Y2Y1OGM2MTY2ZDc4Mzc4
11
+ NTg4MDNlNTQ5YjYxZmVjZGNlODVlYzJmYjliNjRhYWJkOTUyMTU=
12
12
  data.tar.gz: !binary |-
13
- ZjFmZmRjMmY5ODE0MzRhOWQxMmE5MDE4N2ExZmI0YmEwMTllZjA1YWE5ODNk
14
- N2MyN2NlNzQwYzI4MWZiZTVjZmM3MTVlZTFkMGQ1MDlkYTkzODVjNzczNDhm
15
- MzAwY2IxYjU1MzJjMDU2OTRmYmY3ZGI0ODA1NDY5MzBhYjc1MjU=
13
+ MjYyN2YzZjFmOGZjNzE5OGVhNWZlNmYzNTZlY2E0ODVlZWI0Zjk4Y2RmYjkz
14
+ MTE2OGExMWMzN2FiNjRmYWI3M2E5NTlhMDg4YzYwZTU2MTBkY2M3NWFiOWNj
15
+ NTRkN2FiMDI1N2Y5ZTliNzk0ZjQ4N2M5ZmRhM2Y2MGIzOWIxNjQ=
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?201403072353)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403072353)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403080034)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403080034)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
@@ -185,24 +185,13 @@ class Kumogata::ArgumentParser
185
185
 
186
186
  def update_parameters(options)
187
187
  parameters = {}
188
- passwd = options.encryption_password || Kumogata::Crypt.mkpasswd(16)
189
- enc_params = options.encrypt_parameters
190
188
 
191
189
  (options.parameters || []).each do |i|
192
190
  key, value = i.split('=', 2)
193
-
194
- if enc_params and (enc_params.include?('*') or enc_params.include?(key))
195
- value = Kumogata::Crypt.encrypt(passwd, value)
196
- end
197
-
198
191
  parameters[key] = value
199
192
  end
200
193
 
201
194
  options.parameters = parameters
202
-
203
- if options.encrypt_parameters? and not options.skip_send_password?
204
- options.parameters[Kumogata::ENCRYPTION_PASSWORD] = passwd.encode64
205
- end
206
195
  end
207
196
 
208
197
  def scan_args(str)
@@ -355,10 +355,21 @@ class Kumogata::Client
355
355
  if @options.parameters? and not @options.parameters.empty?
356
356
  parameters = {}
357
357
 
358
+ enc_params = @options.encrypt_parameters
359
+ passwd = @options.encryption_password || Kumogata::Crypt.mkpasswd(16)
360
+
358
361
  @options.parameters.each do |key, value|
362
+ if enc_params and (enc_params.include?('*') or enc_params.include?(key))
363
+ value = Kumogata::Crypt.encrypt(passwd, value)
364
+ end
365
+
359
366
  parameters[key] = value
360
367
  end
361
368
 
369
+ if @options.encrypt_parameters? and not @options.skip_send_password?
370
+ parameters[Kumogata::ENCRYPTION_PASSWORD] = passwd.encode64
371
+ end
372
+
362
373
  hash[:parameters] = parameters
363
374
  end
364
375
  end
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.19'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -233,7 +233,7 @@ Outputs do
233
233
  end
234
234
  EOS
235
235
 
236
- run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => true}) do |client, cf|
236
+ run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => ['Password']}) do |client, cf|
237
237
  json = eval_template(template, :update_deletion_policy => true, :add_encryption_password => true).to_json
238
238
 
239
239
  output = make_double('output') do |obj|
@@ -261,7 +261,7 @@ end
261
261
 
262
262
  stacks = make_double('stacks') do |obj|
263
263
  obj.should_receive(:create)
264
- .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large"}}) { stack }
264
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large", "EncryptionPassword"=>"KioqKioqKioqKioqKioqKg=="}}) { stack }
265
265
  obj.should_receive(:[])
266
266
  .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
267
267
  end
@@ -171,7 +171,7 @@ Outputs do
171
171
  end
172
172
  EOS
173
173
 
174
- run_client(:update, :arguments => ['MyStack'], :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => true}) do |client, cf|
174
+ run_client(:update, :arguments => ['MyStack'], :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => ['Password']}) do |client, cf|
175
175
  json = eval_template(template, :add_encryption_password => true).to_json
176
176
 
177
177
  output = make_double('output') do |obj|
@@ -189,7 +189,7 @@ end
189
189
  end
190
190
 
191
191
  stack = make_double('stack') do |obj|
192
- obj.should_receive(:update).with(:template => json, :parameters=>{"InstanceType"=>"m1.large"})
192
+ obj.should_receive(:update).with(:template => json, :parameters=>{"InstanceType"=>"m1.large", "EncryptionPassword"=>"KioqKioqKioqKioqKioqKg=="})
193
193
  obj.should_receive(:status).and_return(
194
194
  'UPDATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_COMPLETE')
195
195
  obj.should_receive(:outputs) { [output] }
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,12 @@ class Kumogata::Utils
12
12
  end
13
13
  end
14
14
 
15
+ class Kumogata::Crypt
16
+ def self.mkpasswd(n)
17
+ '*' * n
18
+ end
19
+ end
20
+
15
21
  def tempfile(content, template_ext)
16
22
  basename = "#{File.basename __FILE__}.#{$$}"
17
23
  basename = [basename, template_ext]
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.19
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara