bora 0.3.0 → 0.4.0

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: c1bb37a94a96c16d392746dd4b9fde60bf77f598
4
- data.tar.gz: 33b5fa1b0aefa84de3bffaaba26ca7868381e7ee
3
+ metadata.gz: a349da3ebed4f64052d4a5b74892d4feb71e7eb6
4
+ data.tar.gz: 5296d29a1a94ea5f06e074a371b92d9a8ab4a573
5
5
  SHA512:
6
- metadata.gz: bd85e49e097d8aa0519601152b6e342d391012c6d6b70d02eae06dd3073382c760d0adb5cdc5ae5e2973b1b5278f697b3fe1f5e4512157cd2d37d989f6b8d33d
7
- data.tar.gz: 3f91f89e9fdd73faba4a40b8da1df84d2f70254efb3de207c31b9004d62cd0ee7f9f376a3ed642f4cf444d4b23745da9e1428d35f4c84fecc80ebcd664c65e92
6
+ metadata.gz: 8b796073ac1b278b8bca0f566e58a257b6bd237666098afae5db59ed7b2b98c2f037ad937ad4298a1eb333a837a1212e40c1ec43d7cb0091d37f65b1a5d5c15f
7
+ data.tar.gz: 325690df797b3c33366ba289fcb2a73a388f1d7f441ae7c8f7c139daa0a19816cbfa4ae6f7430284c74070f479efb9e6fc320f6c723fddce2f4cf9b22ae6321e
data/README.md CHANGED
@@ -39,15 +39,16 @@ end
39
39
  This will give you the following rake tasks
40
40
 
41
41
  ```shell
42
- rake stack:example:apply # Creates (or updates) the example stack
43
- rake stack:example:current_template # Shows the current template for example stack
44
- rake stack:example:delete # Deletes the example stack
45
- rake stack:example:diff # Diffs the new template with the example stack's current template
46
- rake stack:example:events # Outputs the latest events from the example stack
47
- rake stack:example:new_template # Shows the new template for example stack
48
- rake stack:example:recreate # Recreates (deletes then creates) the example stack
49
- rake stack:example:status # Displays the current status of the example stack
50
- rake stack:example:validate # Checks the example stack's template for validity
42
+ rake stack:example:apply # Creates (or updates) the 'example' stack
43
+ rake stack:example:current_template # Shows the current template for 'example' stack
44
+ rake stack:example:delete # Deletes the 'example' stack
45
+ rake stack:example:diff # Diffs the new template with the 'example' stack's current template
46
+ rake stack:example:events # Outputs the latest events from the 'example' stack
47
+ rake stack:example:new_template # Shows the new template for 'example' stack
48
+ rake stack:test:outputs # Shows the outputs from the 'example' stack
49
+ rake stack:example:recreate # Recreates (deletes then creates) the 'example' stack
50
+ rake stack:example:status # Displays the current status of the 'example' stack
51
+ rake stack:example:validate # Checks the 'example' stack's template for validity
51
52
  ```
52
53
 
53
54
  You can add as many templates as you like into your Rakefile, simply define an instance of `Bora::Tasks` for each one.
@@ -0,0 +1,12 @@
1
+ module Bora
2
+ class Output
3
+ def initialize(output)
4
+ @output = output
5
+ end
6
+
7
+ def to_s
8
+ desc = @output.description ? " (#{@output.description})" : ""
9
+ "#{@output.output_key} - #{@output.output_value} #{desc}"
10
+ end
11
+ end
12
+ end
@@ -3,6 +3,7 @@ require 'aws-sdk'
3
3
  require 'diffy'
4
4
  require 'bora/stack_status'
5
5
  require 'bora/event'
6
+ require 'bora/output'
6
7
 
7
8
  module Bora
8
9
  class Stack
@@ -34,11 +35,16 @@ module Bora
34
35
  end
35
36
 
36
37
  def events
37
- return [] if !underlying_stack
38
+ return if !exists?
38
39
  events = @cfn.describe_stack_events({stack_name: underlying_stack.stack_id}).stack_events
39
40
  events.reverse.map { |e| Event.new(e) }
40
41
  end
41
42
 
43
+ def outputs
44
+ return if !exists?
45
+ underlying_stack.outputs.map { |output| Output.new(output) }
46
+ end
47
+
42
48
  def template(pretty = true)
43
49
  return if !exists?
44
50
  template = @cfn.get_template({stack_name: @stack_name}).template_body
@@ -22,6 +22,7 @@ module Bora
22
22
  define_diff_task
23
23
  define_events_task
24
24
  define_new_template_task
25
+ define_outputs_task
25
26
  define_recreate_task
26
27
  define_status_task
27
28
  define_validate_task
@@ -29,7 +30,7 @@ module Bora
29
30
 
30
31
  def define_apply_task
31
32
  within_namespace do
32
- desc "Creates (or updates) the #{@stack_name} stack"
33
+ desc "Creates (or updates) the '#{@stack_name}' stack"
33
34
  task :apply do
34
35
  invoke_action(@stack.exists? ? "update" : "create", stack_options)
35
36
  end
@@ -38,17 +39,17 @@ module Bora
38
39
 
39
40
  def define_current_template_task
40
41
  within_namespace do
41
- desc "Shows the current template for #{@stack_name} stack"
42
+ desc "Shows the current template for '#{@stack_name}' stack"
42
43
  task :current_template do
43
44
  template = @stack.template
44
- puts template ? template : "Stack #{@stack_name} does not exist"
45
+ puts template ? template : "Stack '#{@stack_name}' does not exist"
45
46
  end
46
47
  end
47
48
  end
48
49
 
49
50
  def define_delete_task
50
51
  within_namespace do
51
- desc "Deletes the #{@stack_name} stack"
52
+ desc "Deletes the '#{@stack_name}' stack"
52
53
  task :delete do
53
54
  invoke_action("delete")
54
55
  end
@@ -57,7 +58,7 @@ module Bora
57
58
 
58
59
  def define_diff_task
59
60
  within_namespace do
60
- desc "Diffs the new template with the #{@stack_name} stack's current template"
61
+ desc "Diffs the new template with the '#{@stack_name}' stack's current template"
61
62
  task :diff do
62
63
  puts @stack.diff(@stack_options).to_s(@colorize ? :color : :text)
63
64
  end
@@ -66,13 +67,18 @@ module Bora
66
67
 
67
68
  def define_events_task
68
69
  within_namespace do
69
- desc "Outputs the latest events from the #{@stack_name} stack"
70
+ desc "Outputs the latest events from the '#{@stack_name}' stack"
70
71
  task :events do
71
72
  events = @stack.events
72
- if events.length > 0
73
- @stack.events.each { |e| puts e }
73
+ if events
74
+ if events.length > 0
75
+ puts "Events for stack '#{@stack_name}'"
76
+ @stack.events.each { |e| puts e }
77
+ else
78
+ puts "Stack '#{@stack_name}' has no events"
79
+ end
74
80
  else
75
- puts "No events for stack #{@stack_name}"
81
+ puts "Stack '#{@stack_name}' does not exist"
76
82
  end
77
83
  end
78
84
  end
@@ -80,16 +86,35 @@ module Bora
80
86
 
81
87
  def define_new_template_task
82
88
  within_namespace do
83
- desc "Shows the new template for #{@stack_name} stack"
89
+ desc "Shows the new template for '#{@stack_name}' stack"
84
90
  task :new_template do
85
91
  puts @stack.new_template(@stack_options)
86
92
  end
87
93
  end
88
94
  end
89
95
 
96
+ def define_outputs_task
97
+ within_namespace do
98
+ desc "Shows the outputs from the '#{@stack_name}' stack"
99
+ task :outputs do
100
+ outputs = @stack.outputs
101
+ if outputs
102
+ if outputs.length > 0
103
+ puts "Outputs for stack '#{@stack_name}'"
104
+ outputs.each { |output| puts output }
105
+ else
106
+ puts "Stack '#{@stack_name}' has no outputs"
107
+ end
108
+ else
109
+ puts "Stack '#{@stack_name}' does not exist"
110
+ end
111
+ end
112
+ end
113
+ end
114
+
90
115
  def define_recreate_task
91
116
  within_namespace do
92
- desc "Recreates (deletes then creates) the #{@stack_name} stack"
117
+ desc "Recreates (deletes then creates) the '#{@stack_name}' stack"
93
118
  task :recreate do
94
119
  invoke_action("recreate", stack_options)
95
120
  end
@@ -98,7 +123,7 @@ module Bora
98
123
 
99
124
  def define_status_task
100
125
  within_namespace do
101
- desc "Displays the current status of the #{@stack_name} stack"
126
+ desc "Displays the current status of the '#{@stack_name}' stack"
102
127
  task :status do
103
128
  puts @stack.status
104
129
  end
@@ -107,7 +132,7 @@ module Bora
107
132
 
108
133
  def define_validate_task
109
134
  within_namespace do
110
- desc "Checks the #{@stack_name} stack's template for validity"
135
+ desc "Checks the '#{@stack_name}' stack's template for validity"
111
136
  task :validate do
112
137
  puts "Template for stack '#{@stack_name}' is valid" if @stack.validate(stack_options)
113
138
  end
@@ -115,12 +140,12 @@ module Bora
115
140
  end
116
141
 
117
142
  def invoke_action(action, *args)
118
- puts "#{action.capitalize} stack #{@stack_name}"
143
+ puts "#{action.capitalize} stack '#{@stack_name}'"
119
144
  success = @stack.send(action, *args) { |event| puts event.to_s(colorize) }
120
145
  if success
121
- puts "#{action.capitalize} stack #{@stack_name} completed successfully"
146
+ puts "#{action.capitalize} stack '#{@stack_name}' completed successfully"
122
147
  else
123
- fail("#{action.capitalize} stack #{@stack_name} failed")
148
+ fail("#{action.capitalize} stack '#{@stack_name}' failed")
124
149
  end
125
150
  end
126
151
 
@@ -1,3 +1,3 @@
1
1
  module Bora
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Blaxland
@@ -112,6 +112,7 @@ files:
112
112
  - bora.gemspec
113
113
  - lib/bora.rb
114
114
  - lib/bora/event.rb
115
+ - lib/bora/output.rb
115
116
  - lib/bora/stack.rb
116
117
  - lib/bora/stack_status.rb
117
118
  - lib/bora/status.rb