awspec 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awspec/command/generate.rb +18 -4
- data/lib/awspec/generator.rb +1 -0
- data/lib/awspec/generator/spec/cloudwatch_alarm.rb +40 -0
- data/lib/awspec/helper/finder/cloudwatch.rb +12 -0
- data/lib/awspec/stub/cloudwatch_alarm.rb +1 -1
- data/lib/awspec/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b87cfb8b272ff03a8e80f31c85b578e884156b1
|
4
|
+
data.tar.gz: 4e98b6f864ee384c35c8e2a15f28d1362710d4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d3944ed0f68234739927d07852017014eac9b21299a78a1ca000e0622d75b19f41639930b73577b640713e023c544d18d7e52f543ecddce5550d65e12670cc
|
7
|
+
data.tar.gz: 3ce27c40dac0a0369afb7c460f42ef1c56472bd8092e75d094d1dfd3c25f383a037d3e6eeae51ff285be659e8e6982ff9991b8e71a7521a532004ed8f5e6c795
|
@@ -16,16 +16,30 @@ module Awspec
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
types_for_generate_all = %w(
|
20
|
+
iam_policy cloudwatch_alarm
|
21
|
+
)
|
22
|
+
|
19
23
|
desc 'route53_hosted_zone [example.com.]', 'Generate route53_hosted_zone spec from Domain name'
|
20
24
|
def route53_hosted_zone(hosted_zone)
|
21
25
|
load_secrets
|
22
26
|
puts Awspec::Generator::Spec::Route53HostedZone.new.generate_by_domain_name(hosted_zone)
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
types_for_generate_all = %w(
|
30
|
+
iam_policy cloudwatch_alarm
|
31
|
+
)
|
32
|
+
|
33
|
+
types_for_generate_all.each do |type|
|
34
|
+
if type == 'iam_policy'
|
35
|
+
desc 'iam_policy', 'Generate attached iam_policy spec'
|
36
|
+
else
|
37
|
+
desc type, "Generate #{type} spec"
|
38
|
+
end
|
39
|
+
define_method type do
|
40
|
+
load_secrets
|
41
|
+
eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_all"
|
42
|
+
end
|
29
43
|
end
|
30
44
|
|
31
45
|
no_commands do
|
data/lib/awspec/generator.rb
CHANGED
@@ -8,6 +8,7 @@ require 'awspec/generator/spec/security_group'
|
|
8
8
|
require 'awspec/generator/spec/route53_hosted_zone'
|
9
9
|
require 'awspec/generator/spec/elb'
|
10
10
|
require 'awspec/generator/spec/iam_policy'
|
11
|
+
require 'awspec/generator/spec/cloudwatch_alarm'
|
11
12
|
|
12
13
|
# Doc
|
13
14
|
require 'awspec/generator/doc/type'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class CloudwatchAlarm
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_all
|
6
|
+
alarms = select_all_cloudwatch_alarms
|
7
|
+
alarms.empty? && fail('Not Found alarm')
|
8
|
+
ERB.new(alarm_spec_template, nil, '-').result(binding).chomp
|
9
|
+
end
|
10
|
+
|
11
|
+
def alarm_spec_template
|
12
|
+
template = <<-'EOF'
|
13
|
+
<% alarms.each do |alarm| %>
|
14
|
+
describe cloudwatch_alarm('<%= alarm.alarm_name %>') do
|
15
|
+
it { should exist }
|
16
|
+
<%- alarm.ok_actions.each do |action| -%>
|
17
|
+
it { should have_ok_action('<%= action %>') }
|
18
|
+
<%- end -%>
|
19
|
+
<%- alarm.alarm_actions.each do |action| -%>
|
20
|
+
it { should have_alarm_action('<%= action %>') }
|
21
|
+
<%- end -%>
|
22
|
+
<%- alarm.insufficient_data_actions.each do |action| -%>
|
23
|
+
it { should have_insufficient_data_action('<%= action %>') }
|
24
|
+
<%- end -%>
|
25
|
+
it { should belong_to_metric('<%= alarm.metric_name %>').namespace('<%= alarm.namespace %>') }
|
26
|
+
its(:state_value) { should eq '<%= alarm.state_value %>' }
|
27
|
+
its(:statistic) { should eq '<%= alarm.statistic %>' }
|
28
|
+
its(:period) { should eq <%= alarm.period %> }
|
29
|
+
its(:unit) { should eq '<%= alarm.unit %>' }
|
30
|
+
its(:evaluation_periods) { should eq <%= alarm.evaluation_periods %> }
|
31
|
+
its(:threshold) { should eq <%= alarm.threshold %> }
|
32
|
+
its(:comparison_operator) { should eq '<%= alarm.comparison_operator %>' }
|
33
|
+
end
|
34
|
+
<% end %>
|
35
|
+
EOF
|
36
|
+
template
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -12,6 +12,18 @@ module Awspec::Helper
|
|
12
12
|
alarm[:alarm_arn] == id
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def select_all_cloudwatch_alarms
|
17
|
+
selected = []
|
18
|
+
res = @cloudwatch_client.describe_alarms
|
19
|
+
|
20
|
+
loop do
|
21
|
+
selected += res.metric_alarms
|
22
|
+
(res.next_page? && res = res.next_page) || break
|
23
|
+
end
|
24
|
+
|
25
|
+
selected
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
17
29
|
end
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/awspec/generator/doc/type/ses_identity.rb
|
197
197
|
- lib/awspec/generator/doc/type/subnet.rb
|
198
198
|
- lib/awspec/generator/doc/type/vpc.rb
|
199
|
+
- lib/awspec/generator/spec/cloudwatch_alarm.rb
|
199
200
|
- lib/awspec/generator/spec/ec2.rb
|
200
201
|
- lib/awspec/generator/spec/elb.rb
|
201
202
|
- lib/awspec/generator/spec/iam_policy.rb
|