convection 1.0.3 → 1.0.4

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: 67115b7f8c9dafb09f93733a248cfa00ffdd2564
4
- data.tar.gz: e2d9813955f988796f198c68b3047ea812a1b172
3
+ metadata.gz: 67bf51eb16483fd69d3076cddb1dd2e78dace915
4
+ data.tar.gz: 7bb593969be4f0f776d4129c9435408180a79a9e
5
5
  SHA512:
6
- metadata.gz: 7c2ee15ff3d16828ab27635ba94fb5dc286092414d10340330daae7f01ddb0d1735cb6f797a615e0e25086b1d3cbf3ab1591be3ebf8f098226a428f2b60b613b
7
- data.tar.gz: b3e3c5b978aabfc409e1e619c20e539dce2dbb369c0b9e734c094717ca67f299856d1191045c65012e2bd35f681cbeec7e1bbfa74bb2ada7986274ee4be2cf9b
6
+ metadata.gz: 0120c0fc5b9a7bd2bac857823cf77fa0910d30b464cb18d6e5bade366ff55935e24d0d771acdd00aa0c7d1402a8d8da3e8ae1ceea01254f9b42b4db36ed1a514
7
+ data.tar.gz: 9333ef1c307dc39f36542e878aae36911728d0d8cfda403dc4d93f5cfc499444bfcaf5fee0e8438366b8fce21af3ae01a2fe61e4292d304dc1b875f9ecb84a2f
data/.travis.yml CHANGED
@@ -7,4 +7,5 @@ rvm:
7
7
  - 2.2.0
8
8
  - 2.2.1
9
9
  - 2.2.2
10
+ - 2.3.0
10
11
  sudo: false
@@ -34,6 +34,7 @@ module Convection
34
34
 
35
35
  ## AWS-SDK
36
36
  attr_accessor :region
37
+ attr_accessor :exclude_availability_zones
37
38
  attr_accessor :cloud
38
39
  attr_reader :capabilities
39
40
  attr_accessor :credentials
@@ -108,6 +109,7 @@ module Convection
108
109
  @cloud = options.delete(:cloud)
109
110
  @cloud_name = options.delete(:cloud_name)
110
111
  @region = options.delete(:region) { |_| 'us-east-1' }
112
+ @exclude_availability_zones = options.delete(:exclude_availability_zones) { |_| [] } # Default empty Array
111
113
  @credentials = options.delete(:credentials)
112
114
  @parameters = options.delete(:parameters) { |_| {} } # Default empty hash
113
115
  @tags = options.delete(:tags) { |_| {} } # Default empty hash
@@ -434,7 +436,15 @@ module Convection
434
436
  # the call to ec2 client's describe availability zones
435
437
  def availability_zones(&block)
436
438
  @availability_zones ||=
437
- @ec2_client.describe_availability_zones.availability_zones.map(&:zone_name).sort
439
+ @ec2_client.describe_availability_zones.availability_zones.map(&:zone_name)
440
+
441
+ unless @exclude_availability_zones.empty?
442
+ @availability_zones.reject! { |az| @exclude_availability_zones.include?(az) }
443
+ end
444
+ if @availability_zones.empty? && block
445
+ fail 'There are no AvailabilityZones, check exclude_availability_zones in the Cloudfile.'
446
+ end
447
+ @availability_zones.sort!
438
448
 
439
449
  @availability_zones.each_with_index(&block) if block
440
450
  @availability_zones
@@ -14,6 +14,7 @@ module Convection
14
14
 
15
15
  attribute :name
16
16
  attribute :region
17
+ attribute :exclude_availability_zones
17
18
  attribute :splay
18
19
  attribute :retry_limit
19
20
  attribute :thread_count
@@ -32,6 +33,7 @@ module Convection
32
33
  # @see Convection::Control::Stack#initialize
33
34
  def stack(stack_name, template, options = {}, &block)
34
35
  options[:region] ||= region
36
+ options[:exclude_availability_zones] = exclude_availability_zones
35
37
  options[:cloud] = name
36
38
  options[:attributes] = attributes
37
39
  options[:retry_limit] = retry_limit
@@ -36,6 +36,27 @@ module Convection::Control
36
36
  azs.uniq!
37
37
  expect(azs.size).to be(1)
38
38
  end
39
+
40
+ it 'availability_zones can be ignored' do
41
+ subject.exclude_availability_zones = %w(eu-central-1a)
42
+ expect(subject.availability_zones).to contain_exactly('eu-central-1b')
43
+ end
44
+
45
+ it 'multiple availability_zones can be ignored' do
46
+ subject.exclude_availability_zones = %w(eu-central-1a eu-central-1b)
47
+ expect(subject.availability_zones).to contain_exactly
48
+ end
49
+
50
+ it 'remove all availability_zones fails' do
51
+ subject.exclude_availability_zones = %w(eu-central-1a eu-central-1b)
52
+ b = proc do
53
+ end
54
+ expect { subject.availability_zones(&b) }.to raise_exception(RuntimeError, /AvailabilityZones/)
55
+ end
56
+
57
+ it 'can get default availability_zones' do
58
+ expect(subject.availability_zones).to contain_exactly('eu-central-1a', 'eu-central-1b')
59
+ end
39
60
  end
40
61
  end
41
62
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ module Convection::Model
5
+ describe Cloudfile do
6
+ describe 'stack' do
7
+ subject do
8
+ klass = Class.new
9
+ klass.extend(Convection::DSL::Cloudfile)
10
+ klass
11
+ end
12
+
13
+ it 'can get cloud name' do
14
+ subject.name 'test-1'
15
+ expect(subject.name).to eq('test-1')
16
+ end
17
+
18
+ it 'can get region name' do
19
+ subject.region 'eu-central-1'
20
+ expect(subject.region).to eq('eu-central-1')
21
+ end
22
+
23
+ it 'can exclude_availability_zones an availability_zone' do
24
+ subject.exclude_availability_zones %w(eu-central-1a)
25
+ expect(subject.exclude_availability_zones).to contain_exactly('eu-central-1a')
26
+ end
27
+ end
28
+ end
29
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ SimpleCov.start do
6
6
  end
7
7
 
8
8
  require_relative '../lib/convection'
9
+ require_relative '../lib/convection/model/cloudfile'
9
10
  require_relative './cf_client_context'
10
11
  require_relative './collect_availability_zones_task_context'
11
12
  require_relative './ec2_client_context'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Manero
@@ -276,6 +276,7 @@ files:
276
276
  - spec/convection/control/stack_spec.rb
277
277
  - spec/convection/dsl/intrinsic_functions_spec.rb
278
278
  - spec/convection/model/attributes_spec.rb
279
+ - spec/convection/model/cloudfile_spec.rb
279
280
  - spec/convection/model/template/condition_spec.rb
280
281
  - spec/convection/model/template/resource/aws_auto_scaling_auto_scaling_group_spec.rb
281
282
  - spec/convection/model/template/resource/directoryservice_simple_ad_spec.rb
@@ -344,6 +345,7 @@ test_files:
344
345
  - spec/convection/control/stack_spec.rb
345
346
  - spec/convection/dsl/intrinsic_functions_spec.rb
346
347
  - spec/convection/model/attributes_spec.rb
348
+ - spec/convection/model/cloudfile_spec.rb
347
349
  - spec/convection/model/template/condition_spec.rb
348
350
  - spec/convection/model/template/resource/aws_auto_scaling_auto_scaling_group_spec.rb
349
351
  - spec/convection/model/template/resource/directoryservice_simple_ad_spec.rb