kumogata2 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -0
- data/lib/kumogata2/cli/option_parser.rb +2 -3
- data/lib/kumogata2/client.rb +40 -9
- data/lib/kumogata2/plugin/json.rb +1 -1
- data/lib/kumogata2/plugin/yaml.rb +1 -1
- data/lib/kumogata2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 179adaf126269ec84361603f4195e22424289ac8
|
4
|
+
data.tar.gz: 677c9a57a3a0bb7766831faa888ee3e3c68f3dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a643d946b7c12c60aa438d65fad921960b73fe60a2390ea1abc7078a86c973c5001350f37ebed2837851c3e8c37a0c0422397fef79f5968e08185e3035450e01
|
7
|
+
data.tar.gz: a0414ff4884871e759c44d1d2fef10f22ffcf501958a54a48764b354c35cb92ae138cb2604bfe9552da0f1ee065f0bc3671a9d7f4aeb5c24ea1d0aa3f83058db
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Kumogata2 is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformati
|
|
4
4
|
|
5
5
|
This is a `format converter` + `useful tool`.
|
6
6
|
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/kumogata2.png?201406152020)](http://badge.fury.io/rb/kumogata2)
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Kumogata2::CLI
|
2
2
|
class OptionParser
|
3
3
|
DEFAULT_OPTIONS = {
|
4
|
-
result_log: File.join(Dir.pwd, 'result.
|
5
|
-
command_result_log: File.join(Dir.pwd, 'command_result.json'),
|
4
|
+
result_log: File.join(Dir.pwd, 'result.yaml'),
|
6
5
|
color: $stdout.tty?,
|
7
6
|
}
|
8
7
|
|
@@ -261,7 +260,7 @@ module Kumogata2::CLI
|
|
261
260
|
max = expected.length
|
262
261
|
|
263
262
|
if arguments.length < min or max < arguments.length
|
264
|
-
raise "Usage:
|
263
|
+
raise "Usage: kumogata2 #{command} #{arguments_to_message(expected)} [options]"
|
265
264
|
end
|
266
265
|
end
|
267
266
|
|
data/lib/kumogata2/client.rb
CHANGED
@@ -150,7 +150,7 @@ class Kumogata2::Client
|
|
150
150
|
|
151
151
|
def get_client
|
152
152
|
return @client unless @client.nil?
|
153
|
-
@client = Aws::CloudFormation::Client.new
|
153
|
+
@client = Aws::CloudFormation::Client.new(@options.aws)
|
154
154
|
end
|
155
155
|
|
156
156
|
def get_resource
|
@@ -175,7 +175,7 @@ class Kumogata2::Client
|
|
175
175
|
|
176
176
|
params = {
|
177
177
|
stack_name: stack_name,
|
178
|
-
template_body: template
|
178
|
+
template_body: convert_output_value(template),
|
179
179
|
parameters: parameters_array,
|
180
180
|
}
|
181
181
|
|
@@ -220,7 +220,7 @@ class Kumogata2::Client
|
|
220
220
|
|
221
221
|
params = {
|
222
222
|
stack_name: stack_name,
|
223
|
-
template_body: template
|
223
|
+
template_body: convert_output_value(template),
|
224
224
|
parameters: parameters_array,
|
225
225
|
}
|
226
226
|
|
@@ -285,7 +285,7 @@ class Kumogata2::Client
|
|
285
285
|
end
|
286
286
|
|
287
287
|
def validate_template(template)
|
288
|
-
get_client.validate_template(template_body: template
|
288
|
+
get_client.validate_template(template_body: convert_output_value(template))
|
289
289
|
log(:info, 'Template validated successfully', color: :green)
|
290
290
|
end
|
291
291
|
|
@@ -319,7 +319,7 @@ class Kumogata2::Client
|
|
319
319
|
params = {
|
320
320
|
stack_name: stack_name,
|
321
321
|
change_set_name: change_set_name,
|
322
|
-
template_body: template
|
322
|
+
template_body: convert_output_value(template),
|
323
323
|
parameters: parameters_array,
|
324
324
|
}
|
325
325
|
|
@@ -382,8 +382,12 @@ class Kumogata2::Client
|
|
382
382
|
resp.to_h
|
383
383
|
end
|
384
384
|
|
385
|
+
def get_output_format
|
386
|
+
@options.output_format || 'template'
|
387
|
+
end
|
388
|
+
|
385
389
|
def convert0(template)
|
386
|
-
ext =
|
390
|
+
ext = get_output_format
|
387
391
|
plugin = find_or_create_plugin('xxx.' + ext)
|
388
392
|
|
389
393
|
if plugin
|
@@ -605,13 +609,14 @@ Outputs:
|
|
605
609
|
EOS
|
606
610
|
|
607
611
|
if @options.result_log?
|
612
|
+
logname = get_output_filename(@options.result_log, stack_name)
|
608
613
|
puts <<-EOS
|
609
614
|
|
610
|
-
(Save to `#{
|
615
|
+
(Save to `#{logname}`)
|
611
616
|
EOS
|
612
617
|
|
613
|
-
open(
|
614
|
-
f.puts
|
618
|
+
open(logname, 'wb') do |f|
|
619
|
+
f.puts convert_output_value({
|
615
620
|
'StackName' => stack_name,
|
616
621
|
'StackResourceSummaries' => summaries,
|
617
622
|
'Outputs' => outputs,
|
@@ -620,6 +625,32 @@ EOS
|
|
620
625
|
end
|
621
626
|
end
|
622
627
|
|
628
|
+
def convert_output_value(value)
|
629
|
+
ext = get_output_format
|
630
|
+
Kumogata2::Plugin.plugin_by_name.each do |type, plugin|
|
631
|
+
next unless plugin[:ext].include? ext
|
632
|
+
case type
|
633
|
+
when 'json'
|
634
|
+
return JSON.pretty_generate(value)
|
635
|
+
when 'yaml'
|
636
|
+
return YAML.dump(value)
|
637
|
+
end
|
638
|
+
end
|
639
|
+
value
|
640
|
+
end
|
641
|
+
|
642
|
+
def get_output_filename(value, stack_name = '')
|
643
|
+
ext = get_output_format
|
644
|
+
Kumogata2::Plugin.plugin_by_name.each do |type, plugin|
|
645
|
+
if plugin[:ext].include? ext
|
646
|
+
plugin_ext = plugin[:ext].first
|
647
|
+
filename = stack_name.empty? ? File.basename(value, '.yaml') : stack_name
|
648
|
+
return "#{filename}.#{plugin_ext}"
|
649
|
+
end
|
650
|
+
end
|
651
|
+
value
|
652
|
+
end
|
653
|
+
|
623
654
|
def post_process(path_or_url, outputs)
|
624
655
|
plugin = find_or_create_plugin(path_or_url)
|
625
656
|
|
data/lib/kumogata2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumogata2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.6.11
|
204
204
|
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: Kumogata2 is a tool for AWS CloudFormation.
|