awspec 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -7
- data/doc/_resource_types/lambda.md +3 -0
- data/doc/resource_types.md +12 -0
- data/lib/awspec/generator/doc/type/lambda.rb +17 -0
- data/lib/awspec/helper/finder.rb +3 -0
- data/lib/awspec/helper/finder/lambda.rb +31 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/stub/lambda.rb +18 -0
- data/lib/awspec/type/lambda.rb +31 -0
- data/lib/awspec/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37bdea5e957ae058dcbe8cd39b0aea104eb7b351
|
4
|
+
data.tar.gz: 7aeaef96ed3d595a3b767d36375d5f2ffa7ba61c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c16ac71245320c4be9b6007e924bee29843cdebcfa6c5a41438b89ad4d4d8553dc1d1b49ce8df807d2bad614c5f7fa4ee417d04d13200a6122c9a0757f9b48
|
7
|
+
data.tar.gz: a83b4e57e8630d812cad45aaa94584cbea73a0b630a7ef103fe7363e9154274d313a10762bb2aff86295b89988f93c9ebf1e7bf278a3edd923c5869e338420cc
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
RSpec tests for your AWS resources.
|
4
4
|
|
5
|
+
[Resource Types](doc/resource_types.md)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -89,6 +91,7 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
|
89
91
|
- [x] RouteTable (`route_table`)
|
90
92
|
- [x] EBS Volume (`ebs`)
|
91
93
|
- [x] ELB (`elb`)
|
94
|
+
- [x] Lambda (`lambda`)
|
92
95
|
|
93
96
|
[Resource Types more infomation here](doc/resource_types.md)
|
94
97
|
|
@@ -98,11 +101,6 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
|
98
101
|
- [ ] IAM User
|
99
102
|
- ...
|
100
103
|
|
101
|
-
## TODO
|
102
|
-
|
103
|
-
- [x] Comment format for Document generation
|
104
|
-
- [x] Spec generate command
|
105
|
-
|
106
104
|
## Contributing
|
107
105
|
|
108
106
|
1. Fork it ( https://github.com/k1LoW/awspec/fork )
|
@@ -114,9 +112,9 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
|
114
112
|
### How to add new resource type (ex. Redshift resource)
|
115
113
|
|
116
114
|
1. Create your feature branch (`git checkout -b add-type-redshift`)
|
117
|
-
2. Generate template files (`bundle exec awspec/bin/toolbox template redshift`)
|
115
|
+
2. Generate template files (`bundle exec ./lib/awspec/bin/toolbox template redshift`)
|
118
116
|
3. Fill files with code.
|
119
|
-
4. Generate [doc/resource_types.md](doc/resource_types.md) (`bundle exec awspec/bin/toolbox docgen > doc/resource_type.md`)
|
117
|
+
4. Generate [doc/resource_types.md](doc/resource_types.md) (`bundle exec ./lib/awspec/bin/toolbox docgen > doc/resource_type.md`)
|
120
118
|
5. Run test (`bundle exec rake spec`)
|
121
119
|
6. Push to the branch (`git push origin add-type-redshift`)
|
122
120
|
7. Create a new Pull Request
|
data/doc/resource_types.md
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
| [route_table](#route_table)
|
13
13
|
| [ebs](#ebs)
|
14
14
|
| [elb](#elb)
|
15
|
+
| [lambda](#lambda)
|
15
16
|
|
16
17
|
## <a name="ec2">ec2</a>
|
17
18
|
|
@@ -256,3 +257,14 @@ end
|
|
256
257
|
### belong_to_vpc
|
257
258
|
|
258
259
|
#### its(:health_check_target), its(:health_check_interval), its(:health_check_timeout), its(:health_check_unhealthy_threshold), its(:health_check_healthy_threshold), its(:load_balancer_name), its(:dns_name), its(:canonical_hosted_zone_name), its(:canonical_hosted_zone_name_id), its(:vpc_id), its(:created_time), its(:scheme)
|
260
|
+
## <a name="lambda">lambda</a>
|
261
|
+
|
262
|
+
Lambda resource type.
|
263
|
+
|
264
|
+
### exist
|
265
|
+
|
266
|
+
### have_event_source
|
267
|
+
|
268
|
+
This matcher does not support Amazon S3 event sources. ( [See SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method) )
|
269
|
+
|
270
|
+
#### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Lambda < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'Lambda'
|
8
|
+
@type = Awspec::Type::Lambda.new('my-lambda-function-name')
|
9
|
+
@ret = @type.function
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -8,6 +8,7 @@ require 'awspec/helper/finder/s3'
|
|
8
8
|
require 'awspec/helper/finder/auto_scaling'
|
9
9
|
require 'awspec/helper/finder/ebs'
|
10
10
|
require 'awspec/helper/finder/elb'
|
11
|
+
require 'awspec/helper/finder/lambda'
|
11
12
|
|
12
13
|
module Awspec::Helper
|
13
14
|
module Finder
|
@@ -21,6 +22,7 @@ module Awspec::Helper
|
|
21
22
|
include Awspec::Helper::Finder::AutoScaling
|
22
23
|
include Awspec::Helper::Finder::Ebs
|
23
24
|
include Awspec::Helper::Finder::Elb
|
25
|
+
include Awspec::Helper::Finder::Lambda
|
24
26
|
|
25
27
|
# rubocop:disable all
|
26
28
|
def initialize(id = nil)
|
@@ -30,6 +32,7 @@ module Awspec::Helper
|
|
30
32
|
@s3_client = Aws::S3::Client.new
|
31
33
|
@auto_scaling_client = Aws::AutoScaling::Client.new
|
32
34
|
@elb_client = Aws::ElasticLoadBalancing::Client.new
|
35
|
+
@lambda_client = Aws::Lambda::Client.new
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Awspec::Helper
|
2
|
+
module Finder
|
3
|
+
module Lambda
|
4
|
+
def find_lambda(id)
|
5
|
+
functions = []
|
6
|
+
marker = nil
|
7
|
+
loop do
|
8
|
+
res = @lambda_client.list_functions(
|
9
|
+
marker: marker
|
10
|
+
)
|
11
|
+
marker = res.next_marker
|
12
|
+
break if res.functions.empty?
|
13
|
+
res.functions.each do |function|
|
14
|
+
if function.function_name == id || function.function_arn == id
|
15
|
+
functions.push(function)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
break unless marker
|
19
|
+
end
|
20
|
+
return functions[0] if functions.count == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
def select_event_source_by_function_arn(function_arn)
|
24
|
+
res = @lambda_client.list_event_source_mappings({
|
25
|
+
function_name: function_arn
|
26
|
+
})
|
27
|
+
res[:event_source_mappings]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
Aws.config[:lambda] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_functions: {
|
4
|
+
functions: [
|
5
|
+
{
|
6
|
+
function_name: 'my-lambda-function-name',
|
7
|
+
function_arn: 'arn:aws:lambda:us-east-1:123456789012:function:my-lambda-function-name',
|
8
|
+
runtime: 'nodejs',
|
9
|
+
timeout: 5,
|
10
|
+
memory_size: 256
|
11
|
+
}
|
12
|
+
]
|
13
|
+
},
|
14
|
+
list_event_source_mappings: {
|
15
|
+
# @todo
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class Lambda < Base
|
3
|
+
attr_reader :function
|
4
|
+
|
5
|
+
def initialize(id)
|
6
|
+
super
|
7
|
+
@function = find_lambda(id)
|
8
|
+
@id = @function[:function_arn] if @function
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(name)
|
12
|
+
describe = name.to_sym
|
13
|
+
if @function.members.include?(describe)
|
14
|
+
@function[describe]
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def timeout
|
21
|
+
@function[:timeout]
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_event_source?(event_source_arn)
|
25
|
+
sources = select_event_source_by_function_arn(@id)
|
26
|
+
sources.find do |source|
|
27
|
+
source.event_source_arn == event_source_arn
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- bin/awspec
|
143
143
|
- doc/_resource_types/ec2.md
|
144
144
|
- doc/_resource_types/elb.md
|
145
|
+
- doc/_resource_types/lambda.md
|
145
146
|
- doc/_resource_types/rds_db_parameter_group.md
|
146
147
|
- doc/_resource_types/security_group.md
|
147
148
|
- doc/resource_types.md
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- lib/awspec/generator/doc/type/ebs.rb
|
160
161
|
- lib/awspec/generator/doc/type/ec2.rb
|
161
162
|
- lib/awspec/generator/doc/type/elb.rb
|
163
|
+
- lib/awspec/generator/doc/type/lambda.rb
|
162
164
|
- lib/awspec/generator/doc/type/rds.rb
|
163
165
|
- lib/awspec/generator/doc/type/rds_db_parameter_group.rb
|
164
166
|
- lib/awspec/generator/doc/type/route53_hosted_zone.rb
|
@@ -180,6 +182,7 @@ files:
|
|
180
182
|
- lib/awspec/helper/finder/ebs.rb
|
181
183
|
- lib/awspec/helper/finder/ec2.rb
|
182
184
|
- lib/awspec/helper/finder/elb.rb
|
185
|
+
- lib/awspec/helper/finder/lambda.rb
|
183
186
|
- lib/awspec/helper/finder/rds.rb
|
184
187
|
- lib/awspec/helper/finder/route53.rb
|
185
188
|
- lib/awspec/helper/finder/s3.rb
|
@@ -199,6 +202,7 @@ files:
|
|
199
202
|
- lib/awspec/stub/ebs.rb
|
200
203
|
- lib/awspec/stub/ec2.rb
|
201
204
|
- lib/awspec/stub/elb.rb
|
205
|
+
- lib/awspec/stub/lambda.rb
|
202
206
|
- lib/awspec/stub/rds.rb
|
203
207
|
- lib/awspec/stub/rds_db_parameter_group.rb
|
204
208
|
- lib/awspec/stub/route53_hosted_zone.rb
|
@@ -213,6 +217,7 @@ files:
|
|
213
217
|
- lib/awspec/type/ebs.rb
|
214
218
|
- lib/awspec/type/ec2.rb
|
215
219
|
- lib/awspec/type/elb.rb
|
220
|
+
- lib/awspec/type/lambda.rb
|
216
221
|
- lib/awspec/type/rds.rb
|
217
222
|
- lib/awspec/type/rds_db_parameter_group.rb
|
218
223
|
- lib/awspec/type/route53_hosted_zone.rb
|