awspec 1.18.0 → 1.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 282551e2308dd0173e1945a36abc52c0f7c5836b9a070a73c071385d268b4c21
4
- data.tar.gz: bc12a2007ec95614d27b9d963cf204bcc0f10424fe063d620591e5ddf684a84f
3
+ metadata.gz: caa6a43b5cba1728d82811cc636ba64e94dd1d524dd35c719fa09663d8484c6c
4
+ data.tar.gz: e98167e9eaac8f5620a56b5f4b49e6495f116ad377a634e0fd2fdceb6996adc2
5
5
  SHA512:
6
- metadata.gz: 05bbe8f18a6d921cfa135a2704a643a8ff6970d1975de78af029e1f93214d3ef6ef19199acccde8bba8535a29bc0b4aee9949287647eeae94d9a957aa2a64c7d
7
- data.tar.gz: ddf9edd8742c58ffae8a106f1fe86e41dc38aa8fac3a7b31ed0a2826341a8eb916bb8e8673367f8e2d7149b35cb0530eeb0140e7eae68db55b4f7aa0fc9d999d
6
+ metadata.gz: 66a145fcc87b19afa3fc52ee2cb1f06b71c6d8b98708cfa23bdf1d90e83cc87f26e22288577c97804203461c029d49324ca58c97b7f060db28f1dd71826043a7
7
+ data.tar.gz: 7f1788ca6a3b1e86bd8377c5b342687ace58ad7ecd0764c020a594f5b30c90a57279b0988b8c819c4dfdbb4bb92cbf6266397d95738b69644a12da1a58fcfadf
@@ -20,7 +20,11 @@ module Awspec::Generator
20
20
  name = record_set.name.gsub(/\\052/, '*') # wildcard support
21
21
  if !record_set.resource_records.empty?
22
22
  template = <<-'EOF'
23
+ <% if record_set[:failover] -%>
24
+ it { should have_record_set('<%= name %>').<%= type %>('<%= v %>').ttl(<%= record_set.ttl %>).failover('<%= record_set.failover %>') }
25
+ <%- else -%>
23
26
  it { should have_record_set('<%= name %>').<%= type %>('<%= v %>').ttl(<%= record_set.ttl %>) }
27
+ <% end -%>
24
28
  EOF
25
29
  v = record_set.resource_records.map { |r| r.value }.join("\n")
26
30
  type = record_set.type.downcase
@@ -29,7 +33,11 @@ EOF
29
33
  dns_name = record_set.alias_target.dns_name
30
34
  hosted_zone_id = record_set.alias_target.hosted_zone_id
31
35
  template = <<-'EOF'
36
+ <% if record_set[:failover] -%>
37
+ it { should have_record_set('<%= name %>').alias('<%= dns_name %>', '<%= hosted_zone_id %>').failover('<%= record_set.failover %>') }
38
+ <%- else -%>
32
39
  it { should have_record_set('<%= name %>').alias('<%= dns_name %>', '<%= hosted_zone_id %>') }
40
+ <% end -%>
33
41
  EOF
34
42
  end
35
43
  ERB.new(template, nil, '-').result(binding)
@@ -33,4 +33,9 @@ RSpec::Matchers.define :have_record_set do |name|
33
33
  chain :type do |type|
34
34
  @type = type
35
35
  end
36
+
37
+ chain :failover do |record_type|
38
+ @options = {} if @options.nil?
39
+ @options[:record_type] = record_type
40
+ end
36
41
  end
@@ -26,6 +26,28 @@ Aws.config[:route53] = {
26
26
  }
27
27
  ]
28
28
  },
29
+ {
30
+ name: 'failover.example.com.',
31
+ type: 'A',
32
+ ttl: 3600,
33
+ resource_records: [
34
+ {
35
+ value: '123.456.7.891'
36
+ }
37
+ ],
38
+ failover: 'PRIMARY'
39
+ },
40
+ {
41
+ name: 'failover.example.com.',
42
+ type: 'A',
43
+ ttl: 3600,
44
+ resource_records: [
45
+ {
46
+ value: '123.456.7.892'
47
+ }
48
+ ],
49
+ failover: 'SECONDARY'
50
+ },
29
51
  {
30
52
  name: '\052.example.com.',
31
53
  type: 'CNAME',
@@ -93,6 +115,28 @@ Aws.config[:route53] = {
93
115
  hosted_zone_id: 'Z2ABCDEFGHIJKL',
94
116
  dns_name: 's3-website-us-east-1.amazonaws.com.',
95
117
  evaluate_target_health: false
118
+ },
119
+ failover: 'SECONDARY'
120
+ },
121
+ {
122
+ name: 's3.example.com.',
123
+ type: 'A',
124
+ resource_records: [],
125
+ alias_target: {
126
+ hosted_zone_id: 'Z2FDTNDATAQYW2',
127
+ dns_name: 'abcdefghijklmn.cloudfront.net.',
128
+ evaluate_target_health: false
129
+ },
130
+ failover: 'PRIMARY'
131
+ },
132
+ {
133
+ name: 'alias.example.com.',
134
+ type: 'A',
135
+ resource_records: [],
136
+ alias_target: {
137
+ hosted_zone_id: 'Z2FDTNDATAQYW2',
138
+ dns_name: 'opqrstuvwxyz.cloudfront.net.',
139
+ evaluate_target_health: false
96
140
  }
97
141
  },
98
142
  {
@@ -17,25 +17,47 @@ module Awspec::Type
17
17
 
18
18
  record_sets = resource_via_client_record_sets.select { |record| record.name == name }
19
19
  # Check if the given record is registered regardless of type and value
20
- return !record_sets.empty? if (type || value).nil?
20
+ return !record_sets.empty? if type.nil? && value.nil? && options.nil?
21
21
 
22
22
  record_sets.select! { |record_set| record_set.type.casecmp(type) == 0 }
23
- return !record_sets.empty? unless value
23
+ return !record_sets.empty? if value.nil? && options.nil? || value.nil? && options.empty?
24
+
25
+ return match_failover_record(record_sets, name, value, options) if options[:record_type]
24
26
 
25
27
  record_sets.each do |record_set|
26
- if !record_set.resource_records.empty?
27
- sorted = record_set.resource_records.map { |r| r.value }.sort.join("\n")
28
- ttl = options[:ttl] || record_set[:ttl]
29
- record_set.name == name && \
28
+ return match_record(record_set, name, value, options) unless record_set.resource_records.empty?
29
+ return match_alias_record(record_set, name, options)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def match_failover_record(record_sets, name, value, options)
36
+ record_sets.select! { |record_set| record_set.failover == options[:record_type] }
37
+ return false if record_sets.empty?
38
+ record_sets.each do |record_set|
39
+ return match_alias_record(record_set, name, options) if value.nil?
40
+ return match_record(record_set, name, value, options)
41
+ end
42
+ end
43
+
44
+ def match_record(record_set, name, value, options)
45
+ sorted = record_set.resource_records.map { |r| r.value }.sort.join("\n")
46
+
47
+ if !options.empty? && options[:ttl]
48
+ return (record_set.name == name && \
30
49
  value.split("\n").sort.join("\n") == sorted && \
31
- record_set.ttl == ttl
32
- else
33
- # ALIAS
34
- record_set.name == name && \
35
- record_set.alias_target.dns_name == options[:alias_dns_name] && \
36
- record_set.alias_target.hosted_zone_id == options[:alias_hosted_zone_id]
37
- end
50
+ record_set.ttl == options[:ttl])
38
51
  end
52
+
53
+ record_set.name == name && \
54
+ value.split("\n").sort.join("\n") == sorted
55
+ end
56
+
57
+ def match_alias_record(record_set, name, options)
58
+ record_set.name == name && \
59
+ record_set.alias_target.dns_name == options[:alias_dns_name] && \
60
+ record_set.alias_target.hosted_zone_id == options[:alias_hosted_zone_id]
39
61
  end
40
62
  end
41
63
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.18.0'
2
+ VERSION = '1.18.1'
3
3
  end
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: 1.18.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-17 00:00:00.000000000 Z
11
+ date: 2019-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk