chemtrail 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/lib/templates/config/load_balancer.yml +23 -0
- data/examples/lib/templates/config/nat_device.yml +49 -0
- data/examples/lib/templates/config/opsworks.yml +5 -0
- data/examples/lib/templates/config/private_network.yml +34 -0
- data/examples/lib/templates/config/{resources.yml → public_network.yml} +4 -14
- data/examples/lib/templates/config/public_network_acl.yml +54 -0
- data/examples/lib/templates/config/{mappings.yml → stack.yml} +24 -17
- data/examples/lib/templates/opsworks_vpc/load_balancer.rb +36 -0
- data/examples/lib/templates/opsworks_vpc/nat_device.rb +58 -0
- data/examples/lib/templates/opsworks_vpc/opsworks.rb +27 -0
- data/examples/lib/templates/opsworks_vpc/private_network.rb +89 -0
- data/examples/lib/templates/opsworks_vpc/public_network.rb +79 -0
- data/examples/lib/templates/opsworks_vpc/public_network_acl.rb +72 -0
- data/examples/lib/templates/opsworks_vpc_template.rb +71 -67
- data/examples/spec/lib/templates/opsworks_vpc/load_balancer_spec.rb +22 -0
- data/examples/spec/lib/templates/opsworks_vpc/nat_device_spec.rb +45 -0
- data/examples/spec/lib/templates/opsworks_vpc/opsworks_spec.rb +21 -0
- data/examples/spec/lib/templates/opsworks_vpc/private_network_spec.rb +62 -0
- data/examples/spec/lib/templates/opsworks_vpc/public_network_acl_spec.rb +63 -0
- data/examples/spec/lib/templates/opsworks_vpc/public_network_spec.rb +40 -0
- data/examples/spec/lib/templates/opsworks_vpc_template_spec.rb +37 -39
- data/lib/chemtrail/matchers/be_reference_to.rb +11 -0
- data/lib/chemtrail/matchers/have_entry.rb +36 -0
- data/lib/chemtrail/matchers/have_field.rb +7 -20
- data/lib/chemtrail/matchers/have_mapping.rb +4 -2
- data/lib/chemtrail/matchers/have_output.rb +46 -0
- data/lib/chemtrail/matchers/have_parameter.rb +9 -8
- data/lib/chemtrail/matchers/have_property.rb +35 -20
- data/lib/chemtrail/matchers/have_resource.rb +9 -8
- data/lib/chemtrail/matchers/have_tag.rb +7 -20
- data/lib/chemtrail/reference_presenter.rb +8 -6
- data/lib/chemtrail/rspec.rb +3 -1
- data/lib/chemtrail/version.rb +1 -1
- metadata +24 -6
- data/examples/lib/templates/config/parameters.yml +0 -18
- data/lib/chemtrail/matchers/have_mapping_key.rb +0 -49
@@ -4,24 +4,25 @@ module Chemtrail::RSpec
|
|
4
4
|
extend RSpec::Matchers::DSL
|
5
5
|
|
6
6
|
matcher :have_resource do |resource_id|
|
7
|
-
define_method :resource_for do |
|
8
|
-
|
7
|
+
define_method :resource_for do |resource_list|
|
8
|
+
resource_list.detect { |resource| resource.id == resource_id }
|
9
9
|
end
|
10
10
|
|
11
|
-
define_method :matches_type? do |
|
12
|
-
@type.nil? ||
|
11
|
+
define_method :matches_type? do |resource|
|
12
|
+
@type.nil? || resource.type == @type
|
13
13
|
end
|
14
14
|
|
15
|
-
match do |
|
16
|
-
|
15
|
+
match do |resource_list|
|
16
|
+
resource = resource_for(resource_list)
|
17
|
+
!resource.nil? && matches_type?(resource)
|
17
18
|
end
|
18
19
|
|
19
20
|
chain :with_type do |type|
|
20
21
|
@type = type
|
21
22
|
end
|
22
23
|
|
23
|
-
failure_message_for_should do |
|
24
|
-
if resource = resource_for(
|
24
|
+
failure_message_for_should do |resource_list|
|
25
|
+
if resource = resource_for(resource_list)
|
25
26
|
%(expected resource #{resource_id.inspect} to have type #{@type.inspect}, but got #{resource.type.inspect})
|
26
27
|
else
|
27
28
|
%(expected to find resource #{resource_id.inspect}, but got nothing)
|
@@ -4,10 +4,6 @@ module Chemtrail::RSpec
|
|
4
4
|
extend RSpec::Matchers::DSL
|
5
5
|
|
6
6
|
matcher :have_tag do |key_name|
|
7
|
-
define_method :resource_for do |actual|
|
8
|
-
actual.resources.detect { |resource| resource.id == @resource_id }
|
9
|
-
end
|
10
|
-
|
11
7
|
define_method :tag_for do |resource|
|
12
8
|
tags = resource.properties["Tags"] || []
|
13
9
|
tags.detect { |tag| tag["Key"] == key_name }
|
@@ -23,16 +19,11 @@ module Chemtrail::RSpec
|
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
|
-
match do |
|
27
|
-
resource = resource_for(actual)
|
22
|
+
match do |resource|
|
28
23
|
tag = tag_for(resource)
|
29
24
|
!resource.nil? && !tag.nil? && matches_value?(tag)
|
30
25
|
end
|
31
26
|
|
32
|
-
chain :on do |resource_id|
|
33
|
-
@resource_id = resource_id
|
34
|
-
end
|
35
|
-
|
36
27
|
chain :with_value do |value|
|
37
28
|
@value = value
|
38
29
|
end
|
@@ -41,19 +32,15 @@ module Chemtrail::RSpec
|
|
41
32
|
@reference = reference
|
42
33
|
end
|
43
34
|
|
44
|
-
failure_message_for_should do |
|
45
|
-
if
|
46
|
-
if
|
47
|
-
|
48
|
-
%(expected resource #{@resource_id.inspect} tag #{key_name.inspect} to have value #{@value.inspect}, but got #{tag["Value"].inspect})
|
49
|
-
else
|
50
|
-
%(expected resource #{@resource_id.inspect} tag #{key_name.inspect} to refer to #{@reference.inspect}, but got #{tag["Value"].id.inspect})
|
51
|
-
end
|
35
|
+
failure_message_for_should do |resource|
|
36
|
+
if tag = tag_for(resource)
|
37
|
+
if @value
|
38
|
+
%(expected resource #{resource.id} tag #{key_name.inspect} to have value #{@value.inspect}, but got #{tag["Value"].inspect})
|
52
39
|
else
|
53
|
-
%(expected resource #{
|
40
|
+
%(expected resource #{resource.id} tag #{key_name.inspect} to refer to #{@reference.inspect}, but got #{tag["Value"].id.inspect})
|
54
41
|
end
|
55
42
|
else
|
56
|
-
%(expected to
|
43
|
+
%(expected resource #{resource.id} to have tag #{key_name.inspect})
|
57
44
|
end
|
58
45
|
end
|
59
46
|
end
|
@@ -20,14 +20,16 @@ class Chemtrail::ReferencePresenter
|
|
20
20
|
def to_parameter
|
21
21
|
if reference?
|
22
22
|
argument.to_reference
|
23
|
-
|
24
|
-
if
|
25
|
-
|
23
|
+
else
|
24
|
+
if iterable?
|
25
|
+
if hashlike?
|
26
|
+
argument.reduce(argument) { |h, (k, v)| h[k] = self.class.new(v).to_parameter; h }
|
27
|
+
else
|
28
|
+
argument.map { |item| self.class.new(item).to_parameter }
|
29
|
+
end
|
26
30
|
else
|
27
|
-
argument
|
31
|
+
argument
|
28
32
|
end
|
29
|
-
else
|
30
|
-
argument
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
data/lib/chemtrail/rspec.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "chemtrail"
|
2
|
+
require "chemtrail/matchers/be_reference_to"
|
3
|
+
require "chemtrail/matchers/have_entry"
|
2
4
|
require "chemtrail/matchers/have_field"
|
3
5
|
require "chemtrail/matchers/have_mapping"
|
4
|
-
require "chemtrail/matchers/
|
6
|
+
require "chemtrail/matchers/have_output"
|
5
7
|
require "chemtrail/matchers/have_parameter"
|
6
8
|
require "chemtrail/matchers/have_property"
|
7
9
|
require "chemtrail/matchers/have_resource"
|
data/lib/chemtrail/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chemtrail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doc Ritezel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -101,10 +101,26 @@ files:
|
|
101
101
|
- chemtrail.gemspec
|
102
102
|
- examples/.rspec
|
103
103
|
- examples/Guardfile
|
104
|
-
- examples/lib/templates/config/
|
105
|
-
- examples/lib/templates/config/
|
106
|
-
- examples/lib/templates/config/
|
104
|
+
- examples/lib/templates/config/load_balancer.yml
|
105
|
+
- examples/lib/templates/config/nat_device.yml
|
106
|
+
- examples/lib/templates/config/opsworks.yml
|
107
|
+
- examples/lib/templates/config/private_network.yml
|
108
|
+
- examples/lib/templates/config/public_network.yml
|
109
|
+
- examples/lib/templates/config/public_network_acl.yml
|
110
|
+
- examples/lib/templates/config/stack.yml
|
111
|
+
- examples/lib/templates/opsworks_vpc/load_balancer.rb
|
112
|
+
- examples/lib/templates/opsworks_vpc/nat_device.rb
|
113
|
+
- examples/lib/templates/opsworks_vpc/opsworks.rb
|
114
|
+
- examples/lib/templates/opsworks_vpc/private_network.rb
|
115
|
+
- examples/lib/templates/opsworks_vpc/public_network.rb
|
116
|
+
- examples/lib/templates/opsworks_vpc/public_network_acl.rb
|
107
117
|
- examples/lib/templates/opsworks_vpc_template.rb
|
118
|
+
- examples/spec/lib/templates/opsworks_vpc/load_balancer_spec.rb
|
119
|
+
- examples/spec/lib/templates/opsworks_vpc/nat_device_spec.rb
|
120
|
+
- examples/spec/lib/templates/opsworks_vpc/opsworks_spec.rb
|
121
|
+
- examples/spec/lib/templates/opsworks_vpc/private_network_spec.rb
|
122
|
+
- examples/spec/lib/templates/opsworks_vpc/public_network_acl_spec.rb
|
123
|
+
- examples/spec/lib/templates/opsworks_vpc/public_network_spec.rb
|
108
124
|
- examples/spec/lib/templates/opsworks_vpc_template_spec.rb
|
109
125
|
- examples/spec/spec_helper.rb
|
110
126
|
- lib/chemtrail.rb
|
@@ -113,9 +129,11 @@ files:
|
|
113
129
|
- lib/chemtrail/function.rb
|
114
130
|
- lib/chemtrail/intrinsic.rb
|
115
131
|
- lib/chemtrail/mapping.rb
|
132
|
+
- lib/chemtrail/matchers/be_reference_to.rb
|
133
|
+
- lib/chemtrail/matchers/have_entry.rb
|
116
134
|
- lib/chemtrail/matchers/have_field.rb
|
117
135
|
- lib/chemtrail/matchers/have_mapping.rb
|
118
|
-
- lib/chemtrail/matchers/
|
136
|
+
- lib/chemtrail/matchers/have_output.rb
|
119
137
|
- lib/chemtrail/matchers/have_parameter.rb
|
120
138
|
- lib/chemtrail/matchers/have_property.rb
|
121
139
|
- lib/chemtrail/matchers/have_resource.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
NATInstanceType:
|
2
|
-
Default: m1.small
|
3
|
-
Description: NAT Device EC2 instance type
|
4
|
-
ConstraintDescription: must be a valid EC2 instance type.
|
5
|
-
AllowedValues:
|
6
|
-
- t1.micro
|
7
|
-
- m1.small
|
8
|
-
- m1.medium
|
9
|
-
- m1.large
|
10
|
-
- m1.xlarge
|
11
|
-
- m2.xlarge
|
12
|
-
- m2.2xlarge
|
13
|
-
- m2.4xlarge
|
14
|
-
- c1.medium
|
15
|
-
- c1.xlarge
|
16
|
-
- cc1.4xlarge
|
17
|
-
- cc2.8xlarge
|
18
|
-
- cg1.4xlarge
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "rspec/expectations"
|
2
|
-
|
3
|
-
module Chemtrail::RSpec
|
4
|
-
extend RSpec::Matchers::DSL
|
5
|
-
|
6
|
-
matcher :have_mapping_key do |entry_name|
|
7
|
-
define_method :mapping_for do |actual|
|
8
|
-
actual.mappings.detect { |m| m.id == @mapping_id }
|
9
|
-
end
|
10
|
-
|
11
|
-
define_method :entry_for do |mapping|
|
12
|
-
mapping.entries[entry_name]
|
13
|
-
end
|
14
|
-
|
15
|
-
define_method :matches_value? do |entry|
|
16
|
-
if @included_value
|
17
|
-
entry.values_at(*@included_value.keys) == @included_value.values
|
18
|
-
else
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
match do |actual|
|
24
|
-
mapping = mapping_for(actual)
|
25
|
-
entry = entry_for(mapping)
|
26
|
-
!mapping.nil? && !entry.nil? && matches_value?(entry)
|
27
|
-
end
|
28
|
-
|
29
|
-
chain :on do |mapping_id|
|
30
|
-
@mapping_id = mapping_id
|
31
|
-
end
|
32
|
-
|
33
|
-
chain :including do |value|
|
34
|
-
@included_value = value
|
35
|
-
end
|
36
|
-
|
37
|
-
failure_message_for_should do |actual|
|
38
|
-
if mapping = mapping_for(actual)
|
39
|
-
if entry = entry_for(mapping)
|
40
|
-
%(expected mapping #{@mapping_id.inspect} field #{entry_name.inspect} to have value #{@included_value.inspect}, but got #{entry.inspect})
|
41
|
-
else
|
42
|
-
%(expected mapping #{@mapping_id.inspect} to have type #{entry_name.inspect})
|
43
|
-
end
|
44
|
-
else
|
45
|
-
%(expected to find mapping #{@mapping_id.inspect}, but got nothing)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|