cloudflare-dns-update 2.3.0 → 2.4.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/.travis.yml +15 -12
- data/cloudflare-dns-update.gemspec +6 -4
- data/lib/cloudflare/dns/update/command.rb +38 -43
- data/lib/cloudflare/dns/update/version.rb +1 -1
- data/spec/cloudflare/dns/update/command_spec.rb +7 -15
- metadata +25 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6409c6fe221e5dc21eee10b9f2596347b3efc04fd067bbacefe71ca2b63d211
|
4
|
+
data.tar.gz: b60b29f36731b746f7a2a25efd2dce823280d0a711a313a5d1573cb47bd3c82f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c9ced0e278352962f1efbe644df9d9eb05f8534edc0a62b8a8dcaa63231bf1e0c4903a02b65e4c22f033bc8f6f1a85d4a5741f40b04201a6f33ba92dbd18274
|
7
|
+
data.tar.gz: 9eeb1f04daaa93faaa8c3d1dcb82536e5905afac22be61e835f722323ca14ef561316e102b0347e900fd6d2755ca6ac047c7a3985363fa1648ee96a2146d380f
|
data/.travis.yml
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
dist: trusty
|
2
|
+
dist: xenial
|
4
3
|
cache: bundler
|
5
|
-
|
6
|
-
- 2.0
|
7
|
-
- 2.1
|
8
|
-
- 2.2
|
9
|
-
- 2.3
|
10
|
-
- 2.4
|
11
|
-
- jruby-head
|
12
|
-
- ruby-head
|
4
|
+
|
13
5
|
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.3
|
8
|
+
- rvm: 2.4
|
9
|
+
- rvm: 2.5
|
10
|
+
- rvm: 2.6
|
11
|
+
- rvm: jruby-head
|
12
|
+
env: JRUBY_OPTS="--debug -X+O"
|
13
|
+
- rvm: truffleruby
|
14
|
+
- rvm: ruby-head
|
14
15
|
allow_failures:
|
15
|
-
|
16
|
-
|
16
|
+
- rvm: ruby-head
|
17
|
+
- rvm: jruby-head
|
18
|
+
- rvm: truffleruby
|
19
|
+
|
17
20
|
env:
|
18
21
|
global:
|
19
22
|
secure: LU7mGKnIrWrnrdtq7Ug7HTxzqJoB+NbLHwT8dPmGf4GIfNosO4Jx+G4JLzUd/sCHzUR+XXrsMd7El8WkTVV28+nt6Cv2JvO4EJRIplnAL8Yauc0YSWRwA9nGYhcc2TJc5czbL0mZkJSOv4B+aWco0VWerJfgLYurIA05XrQFGGY=
|
@@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_dependency "samovar", "~> 1.3"
|
26
|
-
spec.add_dependency "tty-prompt", "~> 0.12
|
27
|
-
spec.add_dependency "cloudflare", "~>
|
28
|
-
|
26
|
+
spec.add_dependency "tty-prompt", "~> 0.12"
|
27
|
+
spec.add_dependency "cloudflare", "~> 4.0"
|
28
|
+
|
29
|
+
spec.add_development_dependency 'async-rspec'
|
30
|
+
|
29
31
|
spec.add_development_dependency "rspec", "~> 3.6"
|
30
|
-
spec.add_development_dependency "bundler"
|
32
|
+
spec.add_development_dependency "bundler"
|
31
33
|
spec.add_development_dependency "rake"
|
32
34
|
end
|
@@ -55,15 +55,7 @@ module Cloudflare::DNS::Update
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def logger
|
58
|
-
@logger ||=
|
59
|
-
if verbose?
|
60
|
-
logger.level = Logger::DEBUG
|
61
|
-
elsif quiet?
|
62
|
-
logger.level = Logger::WARN
|
63
|
-
else
|
64
|
-
logger.level = Logger::INFO
|
65
|
-
end
|
66
|
-
end
|
58
|
+
@logger ||= Async.logger
|
67
59
|
end
|
68
60
|
|
69
61
|
def prompt
|
@@ -94,9 +86,9 @@ module Cloudflare::DNS::Update
|
|
94
86
|
def initialize_zone
|
95
87
|
configuration_store.transaction do |configuration|
|
96
88
|
unless configuration[:zone]
|
97
|
-
zone = prompt.select("What zone do you want to update?", @connection.zones
|
89
|
+
zone = prompt.select("What zone do you want to update?", @connection.zones)
|
98
90
|
|
99
|
-
configuration[:zone] = zone.
|
91
|
+
configuration[:zone] = zone.value
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|
@@ -111,9 +103,9 @@ module Cloudflare::DNS::Update
|
|
111
103
|
zone_id = configuration[:zone][:id]
|
112
104
|
zone = @connection.zones.find_by_id(zone_id)
|
113
105
|
|
114
|
-
dns_records = prompt.multi_select("What records do you want to update (select 1 or more)?", zone.dns_records
|
106
|
+
dns_records = prompt.multi_select("What records do you want to update (select 1 or more)?", zone.dns_records)
|
115
107
|
|
116
|
-
domains = configuration[:domains] = dns_records.map(&:
|
108
|
+
domains = configuration[:domains] = dns_records.map(&:value)
|
117
109
|
end
|
118
110
|
end
|
119
111
|
end
|
@@ -126,6 +118,25 @@ module Cloudflare::DNS::Update
|
|
126
118
|
end
|
127
119
|
end
|
128
120
|
|
121
|
+
def update_domain(zone, record, content)
|
122
|
+
if content != record[:content] || @options[:force]
|
123
|
+
logger.info "Content changed #{content.inspect}, updating records..."
|
124
|
+
|
125
|
+
domain = zone.dns_records.find_by_id(record[:id])
|
126
|
+
|
127
|
+
begin
|
128
|
+
domain.update_content(content)
|
129
|
+
|
130
|
+
logger.info "Updated domain: #{record[:name]} #{record[:type]} #{content}"
|
131
|
+
record[:content] = content
|
132
|
+
rescue => error
|
133
|
+
logger.warn("Failed to update domain: #{record[:name]} #{record[:type]} #{content}") {error}
|
134
|
+
end
|
135
|
+
else
|
136
|
+
logger.debug "Content hasn't changed: #{record[:name]} #{record[:type]} #{content}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
129
140
|
def update_domains(content = nil)
|
130
141
|
configuration_store.transaction do |configuration|
|
131
142
|
unless content
|
@@ -136,40 +147,18 @@ module Cloudflare::DNS::Update
|
|
136
147
|
raise RuntimeError.new("Content command failed with non-zero output: #{status}")
|
137
148
|
end
|
138
149
|
|
139
|
-
unless zone = @connection.zones.find_by_id(configuration[:zone][:id])
|
140
|
-
raise RuntimeError.new("Couldn't load zone #{configuration[:zone].inspect} from API!")
|
141
|
-
end
|
142
|
-
|
143
150
|
# Make sure there is no trailing space:
|
144
151
|
content.chomp!
|
145
|
-
end
|
146
|
-
|
147
|
-
if content != configuration[:content] || @options[:force]
|
148
|
-
logger.info "Content changed #{content.inspect}, updating records..."
|
149
152
|
|
150
|
-
configuration[:domains].each do |record|
|
151
|
-
domain = zone.dns_records.find_by_id(record[:id])
|
152
|
-
|
153
|
-
changes = {
|
154
|
-
type: domain.record[:type],
|
155
|
-
name: domain.record[:name],
|
156
|
-
content: content
|
157
|
-
}
|
158
|
-
|
159
|
-
response = domain.put(changes.to_json, content_type: 'application/json')
|
160
|
-
|
161
|
-
if response.successful?
|
162
|
-
logger.info "Updated domain content to #{content}."
|
163
|
-
record[:content] = content
|
164
|
-
else
|
165
|
-
logger.warn "Failed to update domain content to #{content}: #{response.errors.join(', ')}!"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
# Save the last value of content:
|
170
153
|
configuration[:content] = content
|
171
|
-
|
172
|
-
|
154
|
+
end
|
155
|
+
|
156
|
+
unless zone = @connection.zones.find_by_id(configuration[:zone][:id])
|
157
|
+
raise RuntimeError.new("Couldn't load zone #{configuration[:zone].inspect} from API!")
|
158
|
+
end
|
159
|
+
|
160
|
+
configuration[:domains].each do |record|
|
161
|
+
update_domain(zone, record, content)
|
173
162
|
end
|
174
163
|
end
|
175
164
|
|
@@ -182,6 +171,12 @@ module Cloudflare::DNS::Update
|
|
182
171
|
elsif @options[:help]
|
183
172
|
print_usage(program_name)
|
184
173
|
else
|
174
|
+
if verbose?
|
175
|
+
Async.logger.debug!
|
176
|
+
elsif quiet?
|
177
|
+
Async.logger.warn!
|
178
|
+
end
|
179
|
+
|
185
180
|
connect!
|
186
181
|
|
187
182
|
initialize_zone
|
@@ -1,27 +1,19 @@
|
|
1
1
|
|
2
2
|
require 'cloudflare/dns/update/command'
|
3
3
|
|
4
|
-
RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined do
|
4
|
+
RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined, timeout: 60 do
|
5
5
|
include_context Cloudflare::RSpec::Connection
|
6
6
|
|
7
7
|
let(:configuration_path) {File.join(__dir__, 'test.yaml')}
|
8
8
|
|
9
9
|
subject{described_class.new(["-c", configuration_path])}
|
10
10
|
|
11
|
-
let(:zone) {connection.zones.
|
11
|
+
let(:zone) {connection.zones.first}
|
12
12
|
let!(:name) {"dyndns#{ENV['TRAVIS_JOB_ID']}"}
|
13
|
-
let!(:qualified_name) {"#{name}.#{zone.
|
13
|
+
let!(:qualified_name) {"#{name}.#{zone.name}"}
|
14
14
|
|
15
15
|
it "should create dns record" do
|
16
|
-
|
17
|
-
type: "A",
|
18
|
-
name: name,
|
19
|
-
content: "127.0.0.1",
|
20
|
-
ttl: 240,
|
21
|
-
proxied: false
|
22
|
-
}.to_json, content_type: 'application/json')
|
23
|
-
|
24
|
-
expect(response).to be_successful
|
16
|
+
zone.dns_records.create("A", name, "127.0.0.1", ttl: 240, proxied: false)
|
25
17
|
end
|
26
18
|
|
27
19
|
let(:dns_record) {zone.dns_records.find_by_name(qualified_name)}
|
@@ -31,8 +23,8 @@ RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined do
|
|
31
23
|
|
32
24
|
subject.configuration_store.transaction do |configuration|
|
33
25
|
configuration[:content_command] = 'curl -s ipinfo.io/ip'
|
34
|
-
configuration[:zone] = zone.
|
35
|
-
configuration[:domains] = [dns_record.
|
26
|
+
configuration[:zone] = zone.value
|
27
|
+
configuration[:domains] = [dns_record.value]
|
36
28
|
end
|
37
29
|
|
38
30
|
content = subject.update_domains
|
@@ -43,6 +35,6 @@ RSpec.describe Cloudflare::DNS::Update::Command::Top, order: :defined do
|
|
43
35
|
end
|
44
36
|
|
45
37
|
it "should delete dns record" do
|
46
|
-
expect(dns_record.delete).to
|
38
|
+
expect(dns_record.delete).to be_success
|
47
39
|
end
|
48
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare-dns-update
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: samovar
|
@@ -30,28 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.12
|
33
|
+
version: '0.12'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.12
|
40
|
+
version: '0.12'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cloudflare
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: async-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +84,16 @@ dependencies:
|
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - "
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
151
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.6.10
|
152
|
+
rubygems_version: 3.0.1
|
140
153
|
signing_key:
|
141
154
|
specification_version: 4
|
142
155
|
summary: A dyndns client for Cloudflare.
|