kumogata2 0.1.14 → 0.1.15

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: 6db4a45c394094f8864f856bfd395f6f241ced59
4
- data.tar.gz: 770e9b3fed15e232d59bd13bac0bf7aebc619c28
3
+ metadata.gz: f72ddc930b873013eae7ffe270adea2fb9af18b2
4
+ data.tar.gz: 82efb3c67e1884efe560cbb70ca0be4afa90c78b
5
5
  SHA512:
6
- metadata.gz: d7791866506cd56ca7ed5be88e0ab6b619140ae5cb245abbd66fa970056289771219edd834bcef14bd2e9f08df9b4db357fae803c9bc61f6a058b3407662e9f3
7
- data.tar.gz: 02d7c9156d0acd8d96c67a18e83071fdfc24dd7e984a3cbf22590062f8877effd5a0fcc5ad50f9c58107c7444529a6caea91faf3b359356a94db6d6b06ba859c
6
+ metadata.gz: 22f8d4c63bdd2c0442235ba0b5094dc55bcc69fe619e4f46b9dc755f266ef7c7f3c7c70c26eebce4f0e649b00379733a01e0b657218b4cdccf4a37b3d38ec7b1
7
+ data.tar.gz: 432370f671bd0420a449219804bb80ee8931067285db4e2743725f886807d70d53a2967520760449868232ec83799d5b8e241950a9cd5335708f632234712b64
@@ -4,6 +4,7 @@ module Kumogata2::CLI
4
4
  result_log: File.join(Dir.pwd, 'result.yaml'),
5
5
  color: $stdout.tty?,
6
6
  }
7
+ DEFAULT_OPTION_RETRY_LIMIT = 100
7
8
 
8
9
  COMMANDS = {
9
10
  describe: {
@@ -84,7 +85,8 @@ module Kumogata2::CLI
84
85
  arguments = nil
85
86
  # https://github.com/aws/aws-sdk-ruby/blob/v2.3.11/aws-sdk-core/lib/aws-sdk-core/plugins/regional_endpoint.rb#L18
86
87
  region_keys = %w(AWS_REGION AMAZON_REGION AWS_DEFAULT_REGION)
87
- options = {aws: {region: ENV.values_at(*region_keys).compact.first}}
88
+ options = { aws: { region: ENV.values_at(*region_keys).compact.first,
89
+ retry_limit: DEFAULT_OPTION_RETRY_LIMIT } }
88
90
 
89
91
  opt = ::OptionParser.new
90
92
  opt.summary_width = 65535
@@ -93,6 +95,7 @@ module Kumogata2::CLI
93
95
  opt.on('-k', '--access-key ACCESS_KEY') {|v| options[:aws][:access_key_id] = v }
94
96
  opt.on('-s', '--secret-key SECRET_KEY') {|v| options[:aws][:secret_access_key] = v }
95
97
  opt.on('-r', '--region REGION') {|v| options[:aws][:region] = v }
98
+ opt.on('', '--retry-limit LIMIT') {|v| options[:aws][:retry_limit] = v }
96
99
 
97
100
  opt.on('', '--profile PROFILE') do |v|
98
101
  options[:aws][:credentials] ||= {}
@@ -191,7 +191,7 @@ class Kumogata2::Client
191
191
 
192
192
  params = {
193
193
  stack_name: stack_name,
194
- template_body: convert_output_value(template),
194
+ template_body: convert_output_value(template, false),
195
195
  parameters: parameters_array,
196
196
  }
197
197
 
@@ -237,7 +237,7 @@ class Kumogata2::Client
237
237
 
238
238
  params = {
239
239
  stack_name: stack_name,
240
- template_body: convert_output_value(template),
240
+ template_body: convert_output_value(template, false),
241
241
  parameters: parameters_array,
242
242
  }
243
243
 
@@ -303,7 +303,7 @@ class Kumogata2::Client
303
303
  end
304
304
 
305
305
  def validate_template(template)
306
- get_client.validate_template(template_body: convert_output_value(template))
306
+ get_client.validate_template(template_body: convert_output_value(template, false))
307
307
  log(:info, 'Template validated successfully', color: :green)
308
308
  end
309
309
 
@@ -354,7 +354,7 @@ class Kumogata2::Client
354
354
  params = {
355
355
  stack_name: stack_name,
356
356
  change_set_name: change_set_name,
357
- template_body: convert_output_value(template),
357
+ template_body: convert_output_value(template, false),
358
358
  parameters: parameters_array,
359
359
  change_set_type: change_set_type,
360
360
  }
@@ -701,15 +701,17 @@ EOS
701
701
  end
702
702
  end
703
703
 
704
- def convert_output_value(value)
704
+ def convert_output_value(value, color = true)
705
705
  ext = get_output_format
706
706
  Kumogata2::Plugin.plugin_by_name.each do |type, plugin|
707
707
  next unless plugin[:ext].include? ext
708
+
709
+ plugin_instance = find_or_create_plugin('xxx.' + ext)
708
710
  case type
709
711
  when 'json'
710
- return JSON.pretty_generate(value)
712
+ return plugin_instance.dump(value, color)
711
713
  when 'yaml'
712
- return YAML.dump(value)
714
+ return plugin_instance.dump(value, color)
713
715
  end
714
716
  end
715
717
  value
@@ -9,7 +9,11 @@ class Kumogata2::Plugin::JSON
9
9
  JSON.parse(str)
10
10
  end
11
11
 
12
- def dump(hash)
13
- JSON.pretty_generate(hash).colorize_as(:json)
12
+ def dump(hash, color = true)
13
+ if color
14
+ JSON.pretty_generate(hash).colorize_as(:json)
15
+ else
16
+ JSON.pretty_generate(hash)
17
+ end
14
18
  end
15
19
  end
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+
2
3
  class Kumogata2::Plugin::YAML
3
4
  Kumogata2::Plugin.register(:yaml, ['yaml', 'yml', 'template'], self)
4
5
 
@@ -10,7 +11,12 @@ class Kumogata2::Plugin::YAML
10
11
  YAML.load(str)
11
12
  end
12
13
 
13
- def dump(hash)
14
- YAML.dump(hash).colorize_as(:yaml)
14
+ def dump(hash, color = true)
15
+ Hashie.stringify_keys!(hash)
16
+ if color
17
+ YAML.dump(hash).colorize_as(:yaml)
18
+ else
19
+ YAML.dump(hash)
20
+ end
15
21
  end
16
22
  end
@@ -1,3 +1,3 @@
1
1
  module Kumogata2
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
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.14
4
+ version: 0.1.15
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-07-20 00:00:00.000000000 Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk