glare 0.4.0 → 0.6.0
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 +5 -5
- data/glare.gemspec +5 -5
- data/lib/glare.rb +2 -2
- data/lib/glare/cf_dns_record.rb +10 -9
- data/lib/glare/cf_dns_records.rb +2 -1
- data/lib/glare/cf_dns_records/updater.rb +3 -5
- data/lib/glare/dns_record.rb +10 -9
- data/lib/glare/domain.rb +2 -2
- data/lib/glare/domain/record.rb +1 -1
- data/lib/glare/version.rb +1 -1
- data/spec/delete_domain_spec.rb +2 -2
- data/spec/resolve_domain_spec.rb +4 -4
- data/spec/units/glare_spec.rb +8 -8
- data/spec/units/operations_spec.rb +3 -4
- metadata +29 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 27e49ade7bb6778f14de878da4ad2bbc90fdf192542682086c22888805d957fe
|
|
4
|
+
data.tar.gz: d2f684300c0acb3652dccbf0956b28a49a82b016f8cbb0864c48dbc33a2fcba4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0b1b129746cdedf5bd3ac073345396a746e162103802231f3363bcecc39da13ab249abaccae66037bc5607f30570b5538e87760020b0b7f739654a111d75d32
|
|
7
|
+
data.tar.gz: be5bd9e5ebf93bc27ce1e9966ec95f9fd766eae8c9620ec12f0e16f1ed1935342cccd3f49ccc3a11368e78dd49323fc692b654756bc0b69fac2c12f9d56f45d3
|
data/glare.gemspec
CHANGED
|
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.test_files = Dir['spec/**/*.{rb,json}']
|
|
22
22
|
spec.require_paths = ['lib']
|
|
23
23
|
|
|
24
|
-
spec.add_development_dependency 'bundler', '
|
|
25
|
-
spec.add_development_dependency 'rake', '~>
|
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
|
24
|
+
spec.add_development_dependency 'bundler', '>= 1.9'
|
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
|
27
27
|
|
|
28
|
-
spec.add_dependency 'public_suffix'
|
|
29
|
-
spec.add_dependency 'httpclient'
|
|
28
|
+
spec.add_dependency 'public_suffix', '>= 3.0.2', '< 4.0'
|
|
29
|
+
spec.add_dependency 'httpclient', '>= 2.8.3', '< 3.0'
|
|
30
30
|
end
|
data/lib/glare.rb
CHANGED
|
@@ -10,9 +10,9 @@ require 'glare/errors'
|
|
|
10
10
|
|
|
11
11
|
module Glare
|
|
12
12
|
class << self
|
|
13
|
-
def register(fqdn, destination, type)
|
|
13
|
+
def register(fqdn, destination, type, proxied = false)
|
|
14
14
|
client = build_client
|
|
15
|
-
Domain.new(client).register(fqdn, destination, type)
|
|
15
|
+
Domain.new(client).register(fqdn, destination, type, proxied)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def resolve(fqdn, type)
|
data/lib/glare/cf_dns_record.rb
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
module Glare
|
|
2
2
|
class CfDnsRecord
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def initialize(id:, name:, type:, content:)
|
|
3
|
+
def initialize(id:, name:, type:, content:, proxied: false)
|
|
6
4
|
@id = id
|
|
7
5
|
@name = name
|
|
8
6
|
@type = type
|
|
9
7
|
@content = content
|
|
8
|
+
@proxied = proxied
|
|
10
9
|
end
|
|
11
10
|
|
|
12
|
-
def
|
|
13
|
-
@type
|
|
14
|
-
@name
|
|
15
|
-
@content
|
|
11
|
+
def ==(cf_dns_record)
|
|
12
|
+
@type == cf_dns_record.type &&
|
|
13
|
+
@name == cf_dns_record.name &&
|
|
14
|
+
@content == cf_dns_record.content &&
|
|
15
|
+
@proxied == cf_dns_record.proxied
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def to_h
|
|
19
19
|
{
|
|
20
20
|
type: @type,
|
|
21
21
|
name: @name,
|
|
22
|
-
content: @content
|
|
22
|
+
content: @content,
|
|
23
|
+
proxied: @proxied
|
|
23
24
|
}
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
attr_reader :id, :name, :type
|
|
27
|
-
attr_accessor :content
|
|
28
|
+
attr_accessor :content, :proxied
|
|
28
29
|
end
|
|
29
30
|
end
|
data/lib/glare/cf_dns_records.rb
CHANGED
|
@@ -28,16 +28,14 @@ module Glare
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
class Operation
|
|
31
|
-
include Comparable
|
|
32
|
-
|
|
33
31
|
def initialize(record, action)
|
|
34
32
|
@record = record.dup
|
|
35
33
|
@action = action
|
|
36
34
|
end
|
|
37
35
|
|
|
38
|
-
def
|
|
39
|
-
@record
|
|
40
|
-
@action
|
|
36
|
+
def ==(operation)
|
|
37
|
+
@record == operation.record &&
|
|
38
|
+
@action == operation.action
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
attr_reader :action, :record
|
data/lib/glare/dns_record.rb
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
module Glare
|
|
2
2
|
class DnsRecord
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def initialize(name:, type:, content:)
|
|
3
|
+
def initialize(name:, type:, content:, proxied: false)
|
|
6
4
|
@name = name
|
|
7
5
|
@type = type
|
|
8
6
|
@content = content
|
|
7
|
+
@proxied = proxied
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def to_h
|
|
12
11
|
{
|
|
13
12
|
type: @type,
|
|
14
13
|
name: @name,
|
|
15
|
-
content: @content
|
|
14
|
+
content: @content,
|
|
15
|
+
proxied: @proxied
|
|
16
16
|
}
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def
|
|
20
|
-
@type
|
|
21
|
-
@name
|
|
22
|
-
@content
|
|
19
|
+
def ==(dns_record)
|
|
20
|
+
@type == dns_record.type &&
|
|
21
|
+
@name == dns_record.name &&
|
|
22
|
+
@content == dns_record.content &&
|
|
23
|
+
@proxied == dns_record.proxied
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
attr_reader :content, :type, :name
|
|
26
|
+
attr_reader :content, :type, :name, :proxied
|
|
26
27
|
end
|
|
27
28
|
end
|
data/lib/glare/domain.rb
CHANGED
|
@@ -7,9 +7,9 @@ module Glare
|
|
|
7
7
|
@client = client
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def register(fqdn, destinations, type)
|
|
10
|
+
def register(fqdn, destinations, type, proxied = false)
|
|
11
11
|
dns_records = Array(destinations).map do |destination|
|
|
12
|
-
DnsRecord.new(type: type, name: fqdn, content: destination)
|
|
12
|
+
DnsRecord.new(type: type, name: fqdn, content: destination, proxied: proxied)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
zone = Zone.new(@client, fqdn)
|
data/lib/glare/domain/record.rb
CHANGED
data/lib/glare/version.rb
CHANGED
data/spec/delete_domain_spec.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'glare'
|
|
2
2
|
|
|
3
|
-
RSpec.describe 'delete domain' do
|
|
3
|
+
RSpec.describe 'delete domain', integration: true do
|
|
4
4
|
context 'when a domain is registered' do
|
|
5
|
-
let(:domain) { 'a.flywire.
|
|
5
|
+
let(:domain) { 'a.flywire.com.cn' }
|
|
6
6
|
let(:type) { 'A' }
|
|
7
7
|
let(:destination) { ['1.2.3.5', '6.7.8.9'] }
|
|
8
8
|
before do
|
data/spec/resolve_domain_spec.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'glare'
|
|
2
2
|
|
|
3
|
-
RSpec.describe 'Resolve domain' do
|
|
3
|
+
RSpec.describe 'Resolve domain', integration: true do
|
|
4
4
|
context 'when a domain is registered' do
|
|
5
|
-
let(:domain) { 'cname.flywire.
|
|
5
|
+
let(:domain) { 'cname.flywire.com.cn' }
|
|
6
6
|
let(:destination) { ['peertransfer.me'] }
|
|
7
7
|
let(:type) { 'CNAME' }
|
|
8
8
|
|
|
@@ -22,13 +22,13 @@ RSpec.describe 'Resolve domain' do
|
|
|
22
22
|
|
|
23
23
|
it 'raises an exception if api returns error' do
|
|
24
24
|
expect do
|
|
25
|
-
register_domain('error.flywire.
|
|
25
|
+
register_domain('error.flywire.com.cn', '1.1.1.1')
|
|
26
26
|
end.to raise_error(Glare::Errors::ApiError)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
context 'when a domain contains more than one destination' do
|
|
31
|
-
let(:domain) { 'a.flywire.
|
|
31
|
+
let(:domain) { 'a.flywire.com.cn' }
|
|
32
32
|
let(:type) { 'A' }
|
|
33
33
|
before do
|
|
34
34
|
register_domain(domain, destination)
|
data/spec/units/glare_spec.rb
CHANGED
|
@@ -92,7 +92,7 @@ RSpec.describe Glare do
|
|
|
92
92
|
|
|
93
93
|
expect(client).to have_received(:post).with(
|
|
94
94
|
'/zones/9de4eb694c380d79845d35cd939cc7a7/dns_records',
|
|
95
|
-
type: 'CNAME', name: 'not-exist.example.com', content: 'a_destination'
|
|
95
|
+
type: 'CNAME', name: 'not-exist.example.com', content: 'a_destination', proxied: false
|
|
96
96
|
)
|
|
97
97
|
end
|
|
98
98
|
|
|
@@ -109,12 +109,12 @@ RSpec.describe Glare do
|
|
|
109
109
|
|
|
110
110
|
expect(client).to have_received(:post).with(
|
|
111
111
|
'/zones/9de4eb694c380d79845d35cd939cc7a7/dns_records',
|
|
112
|
-
type: 'CNAME', name: 'not-exist.example.com', content: 'a_destination'
|
|
112
|
+
type: 'CNAME', name: 'not-exist.example.com', content: 'a_destination', proxied: false
|
|
113
113
|
)
|
|
114
114
|
|
|
115
115
|
expect(client).to have_received(:post).with(
|
|
116
116
|
'/zones/9de4eb694c380d79845d35cd939cc7a7/dns_records',
|
|
117
|
-
type: 'CNAME', name: 'not-exist.example.com', content: 'another_destination'
|
|
117
|
+
type: 'CNAME', name: 'not-exist.example.com', content: 'another_destination', proxied: false
|
|
118
118
|
)
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -155,7 +155,7 @@ RSpec.describe Glare do
|
|
|
155
155
|
|
|
156
156
|
expect(client).to have_received(:put).with(
|
|
157
157
|
'/zones/9de4eb694c380d79845d35cd939cc7a7/dns_records/a1f984afe5544840505494298f54c33e',
|
|
158
|
-
type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com'
|
|
158
|
+
type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com', proxied: false
|
|
159
159
|
)
|
|
160
160
|
|
|
161
161
|
expect(client).not_to have_received(:put).with(
|
|
@@ -174,12 +174,12 @@ RSpec.describe Glare do
|
|
|
174
174
|
|
|
175
175
|
expect(client).to have_received(:put).with(
|
|
176
176
|
any_args,
|
|
177
|
-
type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com'
|
|
177
|
+
type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com', proxied: false
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
expect(client).to have_received(:put).with(
|
|
181
181
|
any_args,
|
|
182
|
-
type: 'CNAME', name: 'wadus.example.com', content: 'yet_another_destination.com'
|
|
182
|
+
type: 'CNAME', name: 'wadus.example.com', content: 'yet_another_destination.com', proxied: false
|
|
183
183
|
)
|
|
184
184
|
end
|
|
185
185
|
end
|
|
@@ -194,7 +194,7 @@ RSpec.describe Glare do
|
|
|
194
194
|
|
|
195
195
|
expect(client).to have_received(:put).with(
|
|
196
196
|
any_args,
|
|
197
|
-
{ type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com' }
|
|
197
|
+
{ type: 'CNAME', name: 'wadus.example.com', content: 'a_destination.com', proxied: false }
|
|
198
198
|
)
|
|
199
199
|
|
|
200
200
|
expect(client).to have_received(:delete).once
|
|
@@ -215,7 +215,7 @@ RSpec.describe Glare do
|
|
|
215
215
|
|
|
216
216
|
expect(client).to have_received(:post).with(
|
|
217
217
|
'/zones/9de4eb694c380d79845d35cd939cc7a7/dns_records',
|
|
218
|
-
type: 'CNAME', name: 'wadus.example.com', content: 'a_third_destination.com'
|
|
218
|
+
type: 'CNAME', name: 'wadus.example.com', content: 'a_third_destination.com', proxied: false
|
|
219
219
|
)
|
|
220
220
|
end
|
|
221
221
|
end
|
|
@@ -21,7 +21,7 @@ RSpec.describe Glare::CfDnsRecords::Updater do
|
|
|
21
21
|
expect(operations.count).to be_zero
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it 'can
|
|
24
|
+
it 'can detect new records to add when there are some records' do
|
|
25
25
|
current_record = existing_record(content: '1.2.3.4')
|
|
26
26
|
current_records = Glare::CfDnsRecords.new([current_record])
|
|
27
27
|
|
|
@@ -44,10 +44,9 @@ RSpec.describe Glare::CfDnsRecords::Updater do
|
|
|
44
44
|
new_records = [update_record, new_record].shuffle
|
|
45
45
|
|
|
46
46
|
operations = Glare::CfDnsRecords::Updater.new(current_records, new_records).calculate
|
|
47
|
-
add_operation = Glare::CfDnsRecords::Updater::Operation.new(
|
|
47
|
+
add_operation = Glare::CfDnsRecords::Updater::Operation.new(new_records.last, :add)
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
update_operation = Glare::CfDnsRecords::Updater::Operation.new(current_record, :update)
|
|
49
|
+
update_operation = Glare::CfDnsRecords::Updater::Operation.new(new_records.first, :update)
|
|
51
50
|
|
|
52
51
|
expect(operations.insertions).to eq([add_operation])
|
|
53
52
|
expect(operations.updates).to eq([update_operation])
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glare
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jose Luis Salas
|
|
@@ -9,20 +9,20 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- - "
|
|
18
|
+
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
20
|
version: '1.9'
|
|
21
21
|
type: :development
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- - "
|
|
25
|
+
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '1.9'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
@@ -31,56 +31,68 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
34
|
+
version: '12.3'
|
|
35
35
|
type: :development
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
41
|
+
version: '12.3'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: rspec
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
46
|
- - "~>"
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '3.
|
|
48
|
+
version: '3.7'
|
|
49
49
|
type: :development
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
53
|
- - "~>"
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '3.
|
|
55
|
+
version: '3.7'
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: public_suffix
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
60
|
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version:
|
|
62
|
+
version: 3.0.2
|
|
63
|
+
- - "<"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '4.0'
|
|
63
66
|
type: :runtime
|
|
64
67
|
prerelease: false
|
|
65
68
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
69
|
requirements:
|
|
67
70
|
- - ">="
|
|
68
71
|
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
72
|
+
version: 3.0.2
|
|
73
|
+
- - "<"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '4.0'
|
|
70
76
|
- !ruby/object:Gem::Dependency
|
|
71
77
|
name: httpclient
|
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
|
73
79
|
requirements:
|
|
74
80
|
- - ">="
|
|
75
81
|
- !ruby/object:Gem::Version
|
|
76
|
-
version:
|
|
82
|
+
version: 2.8.3
|
|
83
|
+
- - "<"
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '3.0'
|
|
77
86
|
type: :runtime
|
|
78
87
|
prerelease: false
|
|
79
88
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
89
|
requirements:
|
|
81
90
|
- - ">="
|
|
82
91
|
- !ruby/object:Gem::Version
|
|
83
|
-
version:
|
|
92
|
+
version: 2.8.3
|
|
93
|
+
- - "<"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '3.0'
|
|
84
96
|
description:
|
|
85
97
|
email:
|
|
86
98
|
- josacar@users.noreply.github.com
|
|
@@ -140,19 +152,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
152
|
version: '0'
|
|
141
153
|
requirements: []
|
|
142
154
|
rubyforge_project:
|
|
143
|
-
rubygems_version: 2.
|
|
155
|
+
rubygems_version: 2.7.7
|
|
144
156
|
signing_key:
|
|
145
157
|
specification_version: 4
|
|
146
158
|
summary: API client for CloudFlare v4 API
|
|
147
159
|
test_files:
|
|
160
|
+
- spec/units/operations_spec.rb
|
|
148
161
|
- spec/units/api_response_spec.rb
|
|
149
162
|
- spec/units/glare_spec.rb
|
|
150
|
-
- spec/units/operations_spec.rb
|
|
151
|
-
- spec/delete_domain_spec.rb
|
|
152
163
|
- spec/resolve_domain_spec.rb
|
|
153
164
|
- spec/spec_helper.rb
|
|
165
|
+
- spec/delete_domain_spec.rb
|
|
166
|
+
- spec/fixtures/wadus_records_reverse_order.json
|
|
154
167
|
- spec/fixtures/wadus_records.json
|
|
155
168
|
- spec/fixtures/empty_result.json
|
|
156
|
-
- spec/fixtures/list_zone.json
|
|
157
169
|
- spec/fixtures/error_response.json
|
|
158
|
-
- spec/fixtures/
|
|
170
|
+
- spec/fixtures/list_zone.json
|