awspec 0.6.1 → 0.6.2
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 +4 -4
- data/README.md +10 -0
- data/doc/_resource_types/rds_db_parameter_group.md +8 -0
- data/doc/resource_types.md +32 -25
- data/lib/awspec.rb +2 -0
- data/lib/awspec/bin/toolbox +5 -0
- data/lib/awspec/generator.rb +5 -1
- data/lib/awspec/generator/doc/type.rb +26 -0
- data/lib/awspec/generator/doc/type/auto_scaling_group.rb +16 -0
- data/lib/awspec/generator/doc/type/base.rb +89 -0
- data/lib/awspec/generator/doc/type/ebs.rb +17 -0
- data/lib/awspec/generator/doc/type/ec2.rb +17 -0
- data/lib/awspec/generator/doc/type/elb.rb +20 -0
- data/lib/awspec/generator/doc/type/rds.rb +17 -0
- data/lib/awspec/generator/doc/type/rds_db_parameter_group.rb +16 -0
- data/lib/awspec/generator/doc/type/route53_hosted_zone.rb +16 -0
- data/lib/awspec/generator/doc/type/route_table.rb +16 -0
- data/lib/awspec/generator/doc/type/s3.rb +16 -0
- data/lib/awspec/generator/doc/type/security_group.rb +16 -0
- data/lib/awspec/generator/doc/type/subnet.rb +16 -0
- data/lib/awspec/generator/doc/type/vpc.rb +17 -0
- data/lib/awspec/generator/template.rb +100 -0
- data/lib/awspec/stub.rb +7 -0
- data/lib/awspec/stub/auto_scaling_group.rb +87 -0
- data/lib/awspec/stub/ebs.rb +66 -0
- data/lib/awspec/stub/ec2.rb +117 -0
- data/lib/awspec/stub/elb.rb +129 -0
- data/lib/awspec/stub/rds.rb +93 -0
- data/lib/awspec/stub/rds_db_parameter_group.rb +16 -0
- data/lib/awspec/stub/route53_hosted_zone.rb +83 -0
- data/lib/awspec/stub/route_table.rb +60 -0
- data/lib/awspec/stub/s3.rb +14 -0
- data/lib/awspec/stub/security_group.rb +66 -0
- data/lib/awspec/stub/subnet.rb +33 -0
- data/lib/awspec/stub/vpc.rb +69 -0
- data/lib/awspec/toolbox.rb +13 -0
- data/lib/awspec/version.rb +1 -1
- metadata +33 -16
- data/lib/awspec/docgen.rb +0 -23
- data/lib/awspec/generator/doc/auto_scaling_group.rb +0 -15
- data/lib/awspec/generator/doc/base.rb +0 -74
- data/lib/awspec/generator/doc/ebs.rb +0 -15
- data/lib/awspec/generator/doc/ec2.rb +0 -15
- data/lib/awspec/generator/doc/elb.rb +0 -18
- data/lib/awspec/generator/doc/rds.rb +0 -15
- data/lib/awspec/generator/doc/rds_db_parameter_group.rb +0 -15
- data/lib/awspec/generator/doc/route53_hosted_zone.rb +0 -15
- data/lib/awspec/generator/doc/route_table.rb +0 -15
- data/lib/awspec/generator/doc/s3.rb +0 -15
- data/lib/awspec/generator/doc/security_group.rb +0 -15
- data/lib/awspec/generator/doc/subnet.rb +0 -15
- data/lib/awspec/generator/doc/vpc.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 550ef18bd95e67b78e4e77dfb8436ae9f4577bfe
|
4
|
+
data.tar.gz: 27dfa72aea176f0926111f3a4ee1cf61d9206e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c855e75b35e28865fcfb87fb6ade67d2e857b268d8f641d7c3aa64a0e569f51512d8e730c269e4180c1f0ecdf448588c8f133ceece7769f73523583493128a17
|
7
|
+
data.tar.gz: 13d77fdf7d9ea167b11c75a5e3618590a66e354e70b8aa6c00cb14b90bee4a684718acec2c590ea7df45fc83b09effad6e4caa07882269ce604b22db26ff1dfc
|
data/README.md
CHANGED
@@ -111,6 +111,16 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
|
111
111
|
4. Push to the branch (`git push origin my-new-feature`)
|
112
112
|
5. Create a new Pull Request
|
113
113
|
|
114
|
+
### How to add new resource type (ex. Redshift resource)
|
115
|
+
|
116
|
+
1. Create your feature branch (`git checkout -b add-type-redshift`)
|
117
|
+
2. Generate template files (`bundle exec awspec/bin/toolbox template redshift`)
|
118
|
+
3. Fill files with code.
|
119
|
+
4. Generate [doc/resource_types.md](doc/resource_types.md) (`bundle exec awspec/bin/toolbox docgen`)
|
120
|
+
5. Run test (`bundle exec rake spec`)
|
121
|
+
6. Push to the branch (`git push origin add-type-redshift`)
|
122
|
+
7. Create a new Pull Request
|
123
|
+
|
114
124
|
## References
|
115
125
|
|
116
126
|
awspec is inspired by Serverspec.
|
data/doc/resource_types.md
CHANGED
@@ -26,8 +26,6 @@ end
|
|
26
26
|
```
|
27
27
|
|
28
28
|
|
29
|
-
### be_stopped
|
30
|
-
|
31
29
|
### be_pending
|
32
30
|
|
33
31
|
### be_running
|
@@ -40,15 +38,17 @@ end
|
|
40
38
|
|
41
39
|
### be_shutting_down
|
42
40
|
|
43
|
-
###
|
41
|
+
### be_stopped
|
44
42
|
|
45
43
|
### be_stopping
|
46
44
|
|
47
|
-
###
|
45
|
+
### be_terminated
|
46
|
+
|
47
|
+
### have_ebs
|
48
48
|
|
49
49
|
### have_eip
|
50
50
|
|
51
|
-
###
|
51
|
+
### have_security_group
|
52
52
|
|
53
53
|
### belong_to_subnet
|
54
54
|
|
@@ -61,10 +61,6 @@ RDS resource type.
|
|
61
61
|
|
62
62
|
### exist
|
63
63
|
|
64
|
-
### be_upgrading
|
65
|
-
|
66
|
-
### be_storage_full
|
67
|
-
|
68
64
|
### be_available
|
69
65
|
|
70
66
|
### be_backing_up
|
@@ -85,7 +81,7 @@ RDS resource type.
|
|
85
81
|
|
86
82
|
### be_incompatible_parameters
|
87
83
|
|
88
|
-
###
|
84
|
+
### be_incompatible_restore
|
89
85
|
|
90
86
|
### be_maintenance
|
91
87
|
|
@@ -97,7 +93,11 @@ RDS resource type.
|
|
97
93
|
|
98
94
|
### be_resetting_master_credentials
|
99
95
|
|
100
|
-
###
|
96
|
+
### be_restore_error
|
97
|
+
|
98
|
+
### be_storage_full
|
99
|
+
|
100
|
+
### be_upgrading
|
101
101
|
|
102
102
|
### have_db_parameter_group
|
103
103
|
|
@@ -116,6 +116,13 @@ RDS resource type.
|
|
116
116
|
|
117
117
|
RdsDbParameterGroup resource type.
|
118
118
|
|
119
|
+
```ruby
|
120
|
+
describe rds_db_parameter_group('my-rds-db-parameter-group') do
|
121
|
+
its(:basedir) { should eq '/rdsdbbin/mysql' }
|
122
|
+
its(:innodb_buffer_pool_size) { '{DBInstanceClassMemory*3/4}' }
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
119
126
|
### exist
|
120
127
|
|
121
128
|
|
@@ -143,10 +150,10 @@ VPC resource type.
|
|
143
150
|
|
144
151
|
### exist
|
145
152
|
|
146
|
-
### be_pending
|
147
|
-
|
148
153
|
### be_available
|
149
154
|
|
155
|
+
### be_pending
|
156
|
+
|
150
157
|
### have_network_acl
|
151
158
|
|
152
159
|
### have_route_table
|
@@ -187,10 +194,10 @@ Subnet resource type.
|
|
187
194
|
|
188
195
|
### exist
|
189
196
|
|
190
|
-
### be_pending
|
191
|
-
|
192
197
|
### be_available
|
193
198
|
|
199
|
+
### be_pending
|
200
|
+
|
194
201
|
#### its(:subnet_id), its(:state), its(:vpc_id), its(:cidr_block), its(:available_ip_address_count), its(:availability_zone), its(:default_for_az), its(:map_public_ip_on_launch)
|
195
202
|
## <a name="route_table">route_table</a>
|
196
203
|
|
@@ -207,19 +214,19 @@ EBS resource type.
|
|
207
214
|
|
208
215
|
### exist
|
209
216
|
|
210
|
-
###
|
217
|
+
### be_attached_to
|
211
218
|
|
212
|
-
###
|
219
|
+
### be_available
|
213
220
|
|
214
|
-
###
|
221
|
+
### be_creating
|
215
222
|
|
216
|
-
###
|
223
|
+
### be_deleted
|
217
224
|
|
218
|
-
###
|
225
|
+
### be_deleting
|
219
226
|
|
220
|
-
###
|
227
|
+
### be_error
|
221
228
|
|
222
|
-
###
|
229
|
+
### be_in_use
|
223
230
|
|
224
231
|
#### its(:volume_id), its(:size), its(:snapshot_id), its(:availability_zone), its(:state), its(:create_time), its(:volume_type), its(:iops), its(:encrypted), its(:kms_key_id)
|
225
232
|
## <a name="elb">elb</a>
|
@@ -228,6 +235,8 @@ ELB resource type.
|
|
228
235
|
|
229
236
|
### exist
|
230
237
|
|
238
|
+
### have_ec2
|
239
|
+
|
231
240
|
### have_listener
|
232
241
|
|
233
242
|
http://docs.aws.amazon.com/en_us/ElasticLoadBalancing/latest/DeveloperGuide/elb-listener-config.html
|
@@ -238,12 +247,10 @@ describe elb('my-elb') do
|
|
238
247
|
end
|
239
248
|
```
|
240
249
|
|
241
|
-
###
|
250
|
+
### have_security_group
|
242
251
|
|
243
252
|
### have_subnet
|
244
253
|
|
245
|
-
### have_security_group
|
246
|
-
|
247
254
|
### belong_to_subnet
|
248
255
|
|
249
256
|
### belong_to_vpc
|
data/lib/awspec.rb
CHANGED
@@ -3,10 +3,12 @@ require 'rspec'
|
|
3
3
|
require 'rspec/its'
|
4
4
|
require 'awspec/version'
|
5
5
|
require 'awspec/cli'
|
6
|
+
require 'awspec/stub'
|
6
7
|
require 'awspec/matcher'
|
7
8
|
require 'awspec/helper'
|
8
9
|
require 'awspec/ext'
|
9
10
|
require 'awspec/generator'
|
11
|
+
require 'awspec/toolbox'
|
10
12
|
|
11
13
|
module Awspec
|
12
14
|
end
|
data/lib/awspec/generator.rb
CHANGED
@@ -9,6 +9,10 @@ require 'awspec/generator/spec/route53_hosted_zone'
|
|
9
9
|
require 'awspec/generator/spec/elb'
|
10
10
|
|
11
11
|
# Doc
|
12
|
+
require 'awspec/generator/doc/type'
|
12
13
|
types.each do |type|
|
13
|
-
require 'awspec/generator/doc/' + type
|
14
|
+
require 'awspec/generator/doc/type/' + type
|
14
15
|
end
|
16
|
+
|
17
|
+
# Template
|
18
|
+
require 'awspec/generator/template'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
def self.generate_doc
|
5
|
+
Aws.config[:stub_responses] = true
|
6
|
+
types = Awspec::Helper::Type::TYPES
|
7
|
+
types.delete('base')
|
8
|
+
links = types.map do |type|
|
9
|
+
'[' + type + '](#' + type + ')'
|
10
|
+
end
|
11
|
+
header = <<-'EOF'
|
12
|
+
# Resource Types
|
13
|
+
|
14
|
+
<%= links.join("\n| ") %>
|
15
|
+
|
16
|
+
EOF
|
17
|
+
doc = ERB.new(header, nil, '-').result(binding)
|
18
|
+
|
19
|
+
types.map do |type|
|
20
|
+
doc += eval "Awspec::Generator::Doc::Type::#{type.to_camel_case}.new.generate_doc"
|
21
|
+
end
|
22
|
+
doc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class AutoScalingGroup < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::AutoScalingGroup.new('my-auto-scaling-group')
|
8
|
+
@ret = @type.group
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Base
|
5
|
+
def initialize
|
6
|
+
Awspec::Stub.load type_name.to_snake_case
|
7
|
+
@type_name = type_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def type_name
|
11
|
+
self.class.to_s.split('::').last
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_doc
|
15
|
+
@matchers += collect_matchers - @ignore_matchers
|
16
|
+
@matchers.sort! do |a, b|
|
17
|
+
ret = sort_num(a) <=> sort_num(b)
|
18
|
+
next ret if ret != 0
|
19
|
+
a.casecmp(b)
|
20
|
+
end
|
21
|
+
@describes += @ret.members.select do |describe|
|
22
|
+
next true unless @ret[describe].is_a?(Array) || @ret[describe].is_a?(Hash) || @ret[describe].is_a?(Struct)
|
23
|
+
end if @ret.respond_to?(:members)
|
24
|
+
its = @describes.map do |describe|
|
25
|
+
'its(:' + describe.to_s + ')'
|
26
|
+
end
|
27
|
+
|
28
|
+
@descriptions = {}
|
29
|
+
merge_file = File.dirname(__FILE__) + '/../../../../../doc/_resource_types/' + type_name.to_snake_case + '.md'
|
30
|
+
if File.exist?(merge_file)
|
31
|
+
matcher = nil
|
32
|
+
File.foreach(merge_file) do |line|
|
33
|
+
if /\A### (.+)\Z/ =~ line
|
34
|
+
matcher = Regexp.last_match[1]
|
35
|
+
next
|
36
|
+
end
|
37
|
+
@descriptions[matcher] = '' unless @descriptions[matcher]
|
38
|
+
@descriptions[matcher] += line
|
39
|
+
end
|
40
|
+
end
|
41
|
+
ERB.new(doc_template, nil, '-').result(binding)
|
42
|
+
end
|
43
|
+
|
44
|
+
def collect_matchers
|
45
|
+
methods = @type.methods - Awspec::Helper::Finder.instance_methods - Object.methods
|
46
|
+
methods.select! do |method|
|
47
|
+
method.to_s.include?('?')
|
48
|
+
end
|
49
|
+
methods.map! do |method|
|
50
|
+
next 'exist' if 'exists?' == method.to_s
|
51
|
+
next 'have_' + Regexp.last_match[1] if /\Ahas_(.+)\?\z/ =~ method.to_s
|
52
|
+
next 'be_' + Regexp.last_match[1] if /\A(.+)\?\z/ =~ method.to_s
|
53
|
+
method.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def doc_template
|
58
|
+
template = <<-'EOF'
|
59
|
+
## <a name="<%= @type_name.to_snake_case %>"><%= @type_name.to_snake_case %></a>
|
60
|
+
|
61
|
+
<%= @type_name %> resource type.
|
62
|
+
<%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>
|
63
|
+
<% @matchers.each do |matcher| %>
|
64
|
+
### <%= matcher %>
|
65
|
+
<%- if @descriptions.include?(matcher) -%><%= @descriptions[matcher] %><%- end -%>
|
66
|
+
<% end %>
|
67
|
+
<%- unless its.empty? -%>#### <%= its.join(', ') %><%- end -%>
|
68
|
+
<%- if @descriptions.include?('last') -%><%= @descriptions['last'] %><%- end -%>
|
69
|
+
|
70
|
+
EOF
|
71
|
+
template
|
72
|
+
end
|
73
|
+
|
74
|
+
def sort_num(str)
|
75
|
+
case str
|
76
|
+
when 'exist'
|
77
|
+
0
|
78
|
+
when /\Abe_/
|
79
|
+
1
|
80
|
+
when /\Ahave_/
|
81
|
+
2
|
82
|
+
else
|
83
|
+
3
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Ebs < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'EBS'
|
8
|
+
@type = Awspec::Type::Ebs.new('my-ebs')
|
9
|
+
@ret = @type.volume
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Ec2 < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'EC2'
|
8
|
+
@type = Awspec::Type::Ec2.new('my-ec2')
|
9
|
+
@ret = @type.instance
|
10
|
+
@matchers = %w(belong_to_vpc belong_to_subnet)
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Elb < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'ELB'
|
8
|
+
@type = Awspec::Type::Elb.new('my-elb')
|
9
|
+
@ret = @type.lb
|
10
|
+
@matchers = %w(belong_to_vpc belong_to_subnet)
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = %w(
|
13
|
+
health_check_target health_check_interval health_check_timeout
|
14
|
+
health_check_unhealthy_threshold health_check_healthy_threshold
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Rds < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'RDS'
|
8
|
+
@type = Awspec::Type::Rds.new('my-rds')
|
9
|
+
@ret = @type.instance
|
10
|
+
@matchers = %w(belong_to_vpc belong_to_subnet belong_to_db_subnet_group)
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = %w(vpc_id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class RdsDbParameterGroup < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::RdsDbParameterGroup.new('my-rds-db-parameter-group')
|
8
|
+
@ret = @type.parameters
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|