record_store 5.0.3 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/record_store/provider/dnsimple.rb +26 -34
- data/lib/record_store/version.rb +1 -1
- data/record_store.gemspec +1 -1
- data/template/secrets.json +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e8f21e1bb405e185727380fc0c7760116ef5deb
|
4
|
+
data.tar.gz: 29bed06e5aa2e8a4e3f78690015ee3bcc5f96c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d72af6c709460b9b81c44722e6ddd13cfa7f89f18659c7341f7512a6486c44e28364f512d49fee9f16d21240db229d16df07936447f6214356e76a64df862a02
|
7
|
+
data.tar.gz: 35ae3d3718486153cdd9d763de16ca4ef478e0a58f283fd43f6a39a537455547a75687f02daacc8add2db21c3415df42a26308fe08d7ba6691816eb8a551cdb5
|
data/CHANGELOG.md
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'dnsimple'
|
2
2
|
|
3
3
|
module RecordStore
|
4
4
|
class Provider::DNSimple < Provider
|
@@ -9,14 +9,7 @@ module RecordStore
|
|
9
9
|
|
10
10
|
def add(record, zone)
|
11
11
|
record_hash = api_hash(record, zone)
|
12
|
-
res = session.create_record(
|
13
|
-
zone,
|
14
|
-
record_hash.fetch(:name),
|
15
|
-
record.type,
|
16
|
-
record_hash.fetch(:content),
|
17
|
-
ttl: record_hash.fetch(:ttl),
|
18
|
-
priority: record_hash.fetch(:priority, nil)
|
19
|
-
)
|
12
|
+
res = session.zones.create_record(account_id, zone, record_hash)
|
20
13
|
|
21
14
|
if record.type == 'ALIAS'
|
22
15
|
txt_alias = retrieve_current_records(zone: zone).detect do |rr|
|
@@ -29,20 +22,20 @@ module RecordStore
|
|
29
22
|
end
|
30
23
|
|
31
24
|
def remove(record, zone)
|
32
|
-
session.delete_record(zone, record.id)
|
25
|
+
session.zones.delete_record(account_id, zone, record.id)
|
33
26
|
end
|
34
27
|
|
35
28
|
def update(id, record, zone)
|
36
|
-
session.update_record(zone, id, api_hash(record, zone))
|
29
|
+
session.zones.update_record(account_id, zone, id, api_hash(record, zone))
|
37
30
|
end
|
38
31
|
|
39
32
|
# returns an array of Record objects that match the records which exist in the provider
|
40
33
|
def retrieve_current_records(zone:, stdout: $stdout)
|
41
|
-
session.
|
34
|
+
session.zones.all_records(account_id, zone).data.map do |record|
|
42
35
|
begin
|
43
|
-
build_from_api(
|
36
|
+
build_from_api(record, zone)
|
44
37
|
rescue StandardError
|
45
|
-
stdout.puts "Cannot build record: #{
|
38
|
+
stdout.puts "Cannot build record: #{record}"
|
46
39
|
raise
|
47
40
|
end
|
48
41
|
end.compact
|
@@ -50,21 +43,20 @@ module RecordStore
|
|
50
43
|
|
51
44
|
# Returns an array of the zones managed by provider as strings
|
52
45
|
def zones
|
53
|
-
session.zones.map(&:
|
46
|
+
session.zones.all_zones(account_id).data.map(&:name)
|
54
47
|
end
|
55
48
|
|
56
49
|
private
|
57
50
|
|
58
51
|
def session
|
59
|
-
@dns ||=
|
52
|
+
@dns ||= Dnsimple::Client.new(
|
53
|
+
base_url: secrets.fetch('base_url'),
|
54
|
+
access_token: secrets.fetch('api_token')
|
55
|
+
)
|
60
56
|
end
|
61
57
|
|
62
|
-
def
|
63
|
-
|
64
|
-
provider: 'DNSimple',
|
65
|
-
dnsimple_token: secrets.fetch('api_token'),
|
66
|
-
dnsimple_account: secrets.fetch('account_id'),
|
67
|
-
}
|
58
|
+
def account_id
|
59
|
+
@account_id ||= secrets.fetch('account_id')
|
68
60
|
end
|
69
61
|
|
70
62
|
def secrets
|
@@ -72,33 +64,33 @@ module RecordStore
|
|
72
64
|
end
|
73
65
|
|
74
66
|
def build_from_api(api_record, zone)
|
75
|
-
record_type = api_record.
|
67
|
+
record_type = api_record.type
|
76
68
|
record = {
|
77
|
-
record_id: api_record.
|
78
|
-
ttl: api_record.
|
79
|
-
fqdn: api_record.
|
69
|
+
record_id: api_record.id,
|
70
|
+
ttl: api_record.ttl,
|
71
|
+
fqdn: api_record.name.present? ? "#{api_record.name}.#{zone}" : zone,
|
80
72
|
}
|
81
73
|
|
82
74
|
return if record_type == 'SOA'
|
83
75
|
|
84
76
|
case record_type
|
85
77
|
when 'A', 'AAAA'
|
86
|
-
record.merge!(address: api_record.
|
78
|
+
record.merge!(address: api_record.content)
|
87
79
|
when 'ALIAS'
|
88
|
-
record.merge!(alias: api_record.
|
80
|
+
record.merge!(alias: api_record.content)
|
89
81
|
when 'CNAME'
|
90
|
-
record.merge!(cname: api_record.
|
82
|
+
record.merge!(cname: api_record.content)
|
91
83
|
when 'MX'
|
92
|
-
record.merge!(preference: api_record.
|
84
|
+
record.merge!(preference: api_record.priority, exchange: api_record.content)
|
93
85
|
when 'NS'
|
94
|
-
record.merge!(nsdname: api_record.
|
86
|
+
record.merge!(nsdname: api_record.content)
|
95
87
|
when 'SPF', 'TXT'
|
96
|
-
record.merge!(txtdata: api_record.
|
88
|
+
record.merge!(txtdata: api_record.content.gsub(';', '\;'))
|
97
89
|
when 'SRV'
|
98
|
-
weight, port, host = api_record.
|
90
|
+
weight, port, host = api_record.content.split(' ')
|
99
91
|
|
100
92
|
record.merge!(
|
101
|
-
priority: api_record.
|
93
|
+
priority: api_record.priority,
|
102
94
|
weight: weight.to_i,
|
103
95
|
port: port.to_i,
|
104
96
|
target: Record.ensure_ends_with_dot(host),
|
data/lib/record_store/version.rb
CHANGED
data/record_store.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_runtime_dependency 'fog-json'
|
29
29
|
spec.add_runtime_dependency 'fog-xml'
|
30
30
|
spec.add_runtime_dependency 'fog-dynect', '~> 0.2.0'
|
31
|
-
spec.add_runtime_dependency '
|
31
|
+
spec.add_runtime_dependency 'dnsimple-ruby', '~> 2.0'
|
32
32
|
spec.add_runtime_dependency 'google-cloud-dns'
|
33
33
|
|
34
34
|
spec.add_development_dependency 'rake'
|
data/template/secrets.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02-
|
12
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -124,19 +124,19 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.2.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: dnsimple-ruby
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 2.0
|
132
|
+
version: '2.0'
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.0
|
139
|
+
version: '2.0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: google-cloud-dns
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,6 +246,7 @@ extensions: []
|
|
246
246
|
extra_rdoc_files: []
|
247
247
|
files:
|
248
248
|
- ".gitignore"
|
249
|
+
- CHANGELOG.md
|
249
250
|
- Gemfile
|
250
251
|
- LICENSE
|
251
252
|
- README.md
|