convection 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/convection +44 -1
- data/lib/convection/control/stack.rb +2 -0
- data/spec/convection/control/stack/after_create_tasks_spec.rb +1 -1
- data/spec/convection/control/stack/after_delete_tasks_spec.rb +1 -1
- data/spec/convection/control/stack/after_update_tasks_spec.rb +1 -1
- data/spec/convection/control/stack/before_create_tasks_spec.rb +1 -1
- data/spec/convection/control/stack/before_delete_tasks_spec.rb +1 -1
- data/spec/convection/control/stack/before_update_tasks_spec.rb +1 -1
- data/spec/convection/control/stack_spec.rb +41 -0
- data/spec/ec2_client_context.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67115b7f8c9dafb09f93733a248cfa00ffdd2564
|
4
|
+
data.tar.gz: e2d9813955f988796f198c68b3047ea812a1b172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c2ee15ff3d16828ab27635ba94fb5dc286092414d10340330daae7f01ddb0d1735cb6f797a615e0e25086b1d3cbf3ab1591be3ebf8f098226a428f2b60b613b
|
7
|
+
data.tar.gz: b3e3c5b978aabfc409e1e619c20e539dce2dbb369c0b9e734c094717ca67f299856d1191045c65012e2bd35f681cbeec7e1bbfa74bb2ada7986274ee4be2cf9b
|
data/bin/convection
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'thor'
|
3
3
|
require_relative '../lib/convection/control/cloud'
|
4
4
|
require 'thread'
|
5
|
+
require 'yaml'
|
6
|
+
|
5
7
|
module Convection
|
6
8
|
##
|
7
9
|
# Convection CLI
|
@@ -97,6 +99,17 @@ module Convection
|
|
97
99
|
@cloud.stacks[stack].validate
|
98
100
|
end
|
99
101
|
|
102
|
+
desc 'describe-resources', 'Describe resources for a stack'
|
103
|
+
option :cloudfile, :type => :string, :default => 'Cloudfile'
|
104
|
+
option :stack, :desc => 'The stack to be described', :required => true
|
105
|
+
option :type, :desc => 'An optional filter on the types of resources to be described', default: '*'
|
106
|
+
option :properties, :type => :array, :desc => 'A space-separated list of properties to include in the output', default: %w(*)
|
107
|
+
option :format, :type => :string, :default => 'json', :enum => %w(json yaml)
|
108
|
+
def describe_resources
|
109
|
+
init_cloud
|
110
|
+
describe_stack_resources(options[:stack], options[:format], options[:properties], options[:type])
|
111
|
+
end
|
112
|
+
|
100
113
|
no_commands do
|
101
114
|
attr_accessor :last_event
|
102
115
|
|
@@ -178,6 +191,35 @@ module Convection
|
|
178
191
|
end
|
179
192
|
end
|
180
193
|
|
194
|
+
def describe_stack_resources(stack, format, properties_to_include, type)
|
195
|
+
stack_template = @cloud.stacks[stack].current_template
|
196
|
+
raise "No template defined for [#{stack}] stack" if stack_template.nil?
|
197
|
+
|
198
|
+
stack_resources = stack_template['Resources']
|
199
|
+
stack_resources.select! { |_name, attrs| attrs['Type'] == type } unless type == '*'
|
200
|
+
|
201
|
+
described_resources = {}
|
202
|
+
|
203
|
+
stack_resources.each do |name, attrs|
|
204
|
+
# Only include the resource type if we asked for all resource types
|
205
|
+
attrs.reject! { |attr| attr == 'Type' } unless type == '*'
|
206
|
+
|
207
|
+
# Only include those properties that were explicitly requested
|
208
|
+
unless properties_to_include.size == 1 && properties_to_include[0] == '*'
|
209
|
+
attrs['Properties'].select! { |prop| properties_to_include.include? prop }
|
210
|
+
end
|
211
|
+
|
212
|
+
described_resources[name] = attrs
|
213
|
+
end
|
214
|
+
|
215
|
+
case format
|
216
|
+
when 'json'
|
217
|
+
puts JSON.pretty_generate(described_resources)
|
218
|
+
when 'yaml'
|
219
|
+
puts described_resources.to_yaml
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
181
223
|
def emit_events(event, *errors, region: nil)
|
182
224
|
if event.is_a? Model::Event
|
183
225
|
if options[:'very-verbose'] || event.name == :error
|
@@ -197,7 +239,8 @@ module Convection
|
|
197
239
|
end
|
198
240
|
|
199
241
|
errors.each do |error|
|
200
|
-
|
242
|
+
error = RuntimeError.new(error) if error.is_a?(String)
|
243
|
+
say "* #{ error_message }"
|
201
244
|
error.backtrace.each { |trace| say " #{ trace }" }
|
202
245
|
end
|
203
246
|
end
|
@@ -38,7 +38,7 @@ module Convection::Control
|
|
38
38
|
it 'is executed on Stack#apply' do
|
39
39
|
subject.apply
|
40
40
|
|
41
|
-
expect(task.availability_zones).to include('eu-central-1')
|
41
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'is deregistered after Stack#apply is called' do
|
@@ -38,7 +38,7 @@ module Convection::Control
|
|
38
38
|
it 'is executed on Stack#delete' do
|
39
39
|
subject.delete
|
40
40
|
|
41
|
-
expect(task.availability_zones).to include('eu-central-1')
|
41
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'is deregistered after Stack#delete is called' do
|
@@ -41,7 +41,7 @@ module Convection::Control
|
|
41
41
|
it 'is executed on Stack#apply' do
|
42
42
|
subject.apply
|
43
43
|
|
44
|
-
expect(task.availability_zones).to include('eu-central-1')
|
44
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'is deregistered after Stack#apply is called' do
|
@@ -39,7 +39,7 @@ module Convection::Control
|
|
39
39
|
it 'is executed on Stack#apply' do
|
40
40
|
subject.apply
|
41
41
|
|
42
|
-
expect(task.availability_zones).to include('eu-central-1')
|
42
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'is deregistered after Stack#apply is called' do
|
@@ -38,7 +38,7 @@ module Convection::Control
|
|
38
38
|
it 'is executed on Stack#delete' do
|
39
39
|
subject.delete
|
40
40
|
|
41
|
-
expect(task.availability_zones).to include('eu-central-1')
|
41
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'is deregistered after Stack#delete is called' do
|
@@ -42,7 +42,7 @@ module Convection::Control
|
|
42
42
|
it 'is executed on Stack#apply' do
|
43
43
|
subject.apply
|
44
44
|
|
45
|
-
expect(task.availability_zones).to include('eu-central-1')
|
45
|
+
expect(task.availability_zones).to include(a_string_starting_with('eu-central-1'))
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'is deregistered after Stack#apply is called' do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Convection::Control
|
4
|
+
describe Stack do
|
5
|
+
let(:template) do
|
6
|
+
Convection.template do
|
7
|
+
description 'EC2 VPC Test Template'
|
8
|
+
|
9
|
+
ec2_vpc 'TargetVPC' do
|
10
|
+
network '10.0.0.0'
|
11
|
+
subnet_length 24
|
12
|
+
enable_dns
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'stack' do
|
18
|
+
include_context 'with a mock CloudFormation client'
|
19
|
+
include_context 'with a mock EC2 client'
|
20
|
+
|
21
|
+
before do
|
22
|
+
allow(Aws::CloudFormation::Client).to receive(:new).and_return(cf_client)
|
23
|
+
allow(Aws::EC2::Client).to receive(:new).and_return(ec2_client)
|
24
|
+
end
|
25
|
+
subject do
|
26
|
+
Convection::Control::Stack.new('EC2 VPC Test Stack', template)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'availability_zones are stored in an array' do
|
30
|
+
expect(subject.availability_zones).to be_a(Array)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'availability_zones are in the same region' do
|
34
|
+
azs = subject.availability_zones
|
35
|
+
azs.map! { |r| r.match(/(\w{2}-\w+-\d)/)[1] }
|
36
|
+
azs.uniq!
|
37
|
+
expect(azs.size).to be(1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/ec2_client_context.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -273,6 +273,7 @@ files:
|
|
273
273
|
- spec/convection/control/stack/before_create_tasks_spec.rb
|
274
274
|
- spec/convection/control/stack/before_delete_tasks_spec.rb
|
275
275
|
- spec/convection/control/stack/before_update_tasks_spec.rb
|
276
|
+
- spec/convection/control/stack_spec.rb
|
276
277
|
- spec/convection/dsl/intrinsic_functions_spec.rb
|
277
278
|
- spec/convection/model/attributes_spec.rb
|
278
279
|
- spec/convection/model/template/condition_spec.rb
|
@@ -340,6 +341,7 @@ test_files:
|
|
340
341
|
- spec/convection/control/stack/before_create_tasks_spec.rb
|
341
342
|
- spec/convection/control/stack/before_delete_tasks_spec.rb
|
342
343
|
- spec/convection/control/stack/before_update_tasks_spec.rb
|
344
|
+
- spec/convection/control/stack_spec.rb
|
343
345
|
- spec/convection/dsl/intrinsic_functions_spec.rb
|
344
346
|
- spec/convection/model/attributes_spec.rb
|
345
347
|
- spec/convection/model/template/condition_spec.rb
|