kumogata 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1646d7c3f03a1b105c5a5bc6ca27a69d88ce7a0
4
- data.tar.gz: 9de11baa1375551eaf9458b6d88bf73aed447210
3
+ metadata.gz: 9f4c18be7f8c6709036ac84848b986f07c265e32
4
+ data.tar.gz: 5e47465957e49072b5ba4d3a7b47d3c9c6ebab86
5
5
  SHA512:
6
- metadata.gz: f5aecb29d489251c22ece46f7460ae4405bc589dd363ae89b4e8be3b3652f978919a82b885d2363787caa2b7e1b2eb914a804665cff673cb9ddbdfd7523f09ac
7
- data.tar.gz: 54724f7d9f9af6067f59c4e1e2ee7a51dd198a98a5b9b9ad5dc6380657584378bbca1f550ab34182fe650c4a273d71cb9f6ba4eeb7b46c4366d73e79fd211e9e
6
+ metadata.gz: c62012998716bbbd4b90a377ffcb06861a246a7d338da5064564a34fc72371d0c0d6ee083182bac71801f695a78fc68f443f9c62a19419d04c312e7e5e22abcf
7
+ data.tar.gz: 8544c375e53b762c98000896c6ef4e0b098cb4a6b48113806dfa7206215e54d98b836fe4d112c377a6e0c16e09cd8ca4aab593f752f2e37bee04d28e2e17048c
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?201403151812)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403151812)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403151823)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403151823)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
@@ -54,6 +54,8 @@ end
54
54
 
55
55
  Ruby template structure is almost the same as [JSON template](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-structure.html).
56
56
 
57
+ (**You can also use JSON templates**)
58
+
57
59
  ## Installation
58
60
 
59
61
  $ gem install kumogata
@@ -74,7 +76,7 @@ Commands:
74
76
  show-events STACK_NAME Show events for a specified stack
75
77
  show-outputs STACK_NAME Show outputs for a specified stack
76
78
  show-resources STACK_NAME Show resources for a specified stack
77
- diff PATH_OR_URL1 PATH_OR_URL2 Compare templates logically
79
+ diff PATH_OR_URL1 PATH_OR_URL2 Compare templates logically (file, http://..., stack://...)
78
80
 
79
81
  Options:
80
82
  -k, --access-key ACCESS_KEY
@@ -95,6 +97,7 @@ Options:
95
97
  --command-result-log PATH
96
98
  --force
97
99
  -w, --ignore-all-space
100
+ --color
98
101
  --no-color
99
102
  --debug
100
103
  ```
@@ -72,7 +72,16 @@ class Kumogata::Client
72
72
  validate_stack_name(stack_name)
73
73
 
74
74
  template = export_template(stack_name)
75
- devaluate_template(template).chomp.colorize_as(:ruby)
75
+ format = @options.format || :ruby
76
+
77
+ case format
78
+ when :ruby
79
+ devaluate_template(template).chomp.colorize_as(:ruby)
80
+ when :json
81
+ JSON.pretty_generate(template).colorize_as(:json)
82
+ else
83
+ raise "Unknown format: #{format}"
84
+ end
76
85
  end
77
86
 
78
87
  def show_events(stack_name)
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -56,4 +56,67 @@ Outputs do
56
56
  end
57
57
  EOS
58
58
  end
59
+
60
+ it 'export a JSON template' do
61
+ json = <<-EOS
62
+ {
63
+ "Resources": {
64
+ "myEC2Instance": {
65
+ "Type": "AWS::EC2::Instance",
66
+ "Properties": {
67
+ "ImageId": "ami-XXXXXXXX",
68
+ "InstanceType": "t1.micro"
69
+ }
70
+ }
71
+ },
72
+ "Outputs": {
73
+ "AZ": {
74
+ "Value": {
75
+ "Fn::GetAtt": [
76
+ "myEC2Instance",
77
+ "AvailabilityZone"
78
+ ]
79
+ }
80
+ }
81
+ }
82
+ }
83
+ EOS
84
+
85
+ template = run_client(:export, :arguments => ['MyStack'], :options => {:format => :json}) do |client, cf|
86
+ stack = make_double('stack') do |obj|
87
+ obj.should_receive(:status) { 'CREATE_COMPLETE' }
88
+ obj.should_receive(:template) { json }
89
+ end
90
+
91
+ stacks = make_double('stacks') do |obj|
92
+ obj.should_receive(:[]).with('MyStack') { stack }
93
+ end
94
+
95
+ cf.should_receive(:stacks) { stacks }
96
+ end
97
+
98
+ expect(template).to eq((<<-EOS).chomp)
99
+ {
100
+ "Resources": {
101
+ "myEC2Instance": {
102
+ "Type": "AWS::EC2::Instance",
103
+ "Properties": {
104
+ "ImageId": "ami-XXXXXXXX",
105
+ "InstanceType": "t1.micro"
106
+ }
107
+ }
108
+ },
109
+ "Outputs": {
110
+ "AZ": {
111
+ "Value": {
112
+ "Fn::GetAtt": [
113
+ "myEC2Instance",
114
+ "AvailabilityZone"
115
+ ]
116
+ }
117
+ }
118
+ }
119
+ }
120
+ EOS
121
+ end
59
122
  end
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.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara