record_store 6.5.4 → 6.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -5
- data/CHANGELOG.md +3 -0
- data/lib/record_store/cli.rb +6 -8
- data/lib/record_store/provider/dnsimple/patch_request_error_to_include_errors.rb +20 -0
- data/lib/record_store/provider/dnsimple.rb +5 -6
- data/lib/record_store/provider/dynect.rb +3 -5
- data/lib/record_store/provider/google_cloud_dns.rb +9 -13
- data/lib/record_store/provider/ns1.rb +1 -1
- data/lib/record_store/provider.rb +17 -18
- data/lib/record_store/version.rb +1 -1
- data/lib/record_store/zone/config/implicit_record_template.rb +2 -2
- data/lib/record_store/zone/yaml_definitions.rb +1 -1
- data/lib/record_store/zone.rb +3 -5
- data/lib/record_store.rb +2 -2
- data/record_store.gemspec +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d08c3213971934f91db50a1f602c45e7110ec2f73c71bde5b02dcff1fd2e0731
|
4
|
+
data.tar.gz: 478970b2e7adf68a312544f97c0effd775398517340344d2eb6e0fdfc23c3cd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c67e750aedfdf0d8d9e5dc5bbb8ca01c2b5a0cd68a880f67fdc8f2094805b3ee8b231303b2f65c6f1012873f15a23a3383de786b7c44dc62cbf7eca2709058bb
|
7
|
+
data.tar.gz: 2d774dae370703a8807d7b91e4dbe50a1186ba920d7df2b8a3bf3276e930fb1f4342a050bdfcc84f8fdfae0231692064e969911452c0631f25809cd2da9aaca5
|
data/.rubocop.yml
CHANGED
@@ -1,19 +1,40 @@
|
|
1
|
-
|
2
|
-
-
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-shopify: rubocop.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion: 2.4
|
5
|
+
TargetRubyVersion: 2.6.4
|
6
6
|
Exclude:
|
7
7
|
- vendor/**/*
|
8
8
|
UseCache: true
|
9
9
|
CacheRootDirectory: tmp/rubocop
|
10
10
|
|
11
|
+
Naming/InclusiveLanguage:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/ClassAndModuleChildren:
|
15
|
+
Enabled: false
|
16
|
+
|
11
17
|
Style/FrozenStringLiteralComment:
|
12
18
|
Enabled: false
|
13
19
|
|
20
|
+
Style/QuotedSymbols:
|
21
|
+
Enabled: false
|
22
|
+
|
14
23
|
Style/MethodCallWithArgsParentheses:
|
15
24
|
Include:
|
16
25
|
- '**/*.rb'
|
17
26
|
|
18
|
-
Style/
|
19
|
-
Enabled: false
|
27
|
+
Style/StringLiterals:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/StringLiteralsInInterpolation:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/TrailingCommaInArrayLiteral:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/TrailingCommaInHashLiteral:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/WordArray:
|
40
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/lib/record_store/cli.rb
CHANGED
@@ -193,14 +193,12 @@ module RecordStore
|
|
193
193
|
|
194
194
|
desc 'secrets', 'Decrypts DynECT credentials'
|
195
195
|
def secrets
|
196
|
-
environment =
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
'dev'
|
203
|
-
end
|
196
|
+
environment = if ENV['PRODUCTION']
|
197
|
+
'production'
|
198
|
+
elsif ENV['CI']
|
199
|
+
'ci'
|
200
|
+
else
|
201
|
+
'dev'
|
204
202
|
end
|
205
203
|
|
206
204
|
secrets = %x(ejson decrypt #{RecordStore.secrets_path.sub(/\.json\z/, ".#{environment}.ejson")})
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
class RequestError < Error
|
3
|
+
private
|
4
|
+
|
5
|
+
alias_method :original_message_from, :message_from
|
6
|
+
|
7
|
+
def message_from(http_response)
|
8
|
+
message = original_message_from(http_response)
|
9
|
+
return unless json_response?(http_response)
|
10
|
+
|
11
|
+
base_error = http_response.parsed_response.dig("errors", "base")&.join(", ")
|
12
|
+
message += ": #{base_error}" unless base_error.nil?
|
13
|
+
message
|
14
|
+
end
|
15
|
+
|
16
|
+
def json_response?(http_response)
|
17
|
+
http_response.headers["Content-Type"]&.start_with?("application/json")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'dnsimple'
|
2
2
|
require_relative 'dnsimple/patch_api_header'
|
3
|
+
require_relative 'dnsimple/patch_request_error_to_include_errors'
|
3
4
|
|
4
5
|
module RecordStore
|
5
6
|
class Provider::DNSimple < Provider
|
@@ -20,12 +21,10 @@ module RecordStore
|
|
20
21
|
def retrieve_current_records(zone:, stdout: $stdout)
|
21
22
|
retry_on_connection_errors do
|
22
23
|
session.zones.all_records(account_id, zone).data.map do |record|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
raise
|
28
|
-
end
|
24
|
+
build_from_api(record, zone)
|
25
|
+
rescue StandardError
|
26
|
+
stdout.puts "Cannot build record: #{record}"
|
27
|
+
raise
|
29
28
|
end.compact
|
30
29
|
end
|
31
30
|
end
|
@@ -36,11 +36,9 @@ module RecordStore
|
|
36
36
|
def retrieve_current_records(zone:, stdout: $stdout)
|
37
37
|
session.get_all_records(zone).body.fetch('data').flat_map do |_type, records|
|
38
38
|
records.map do |record_body|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
stdout.puts "Cannot build record: #{record_body}"
|
43
|
-
end
|
39
|
+
build_from_api(record_body)
|
40
|
+
rescue StandardError
|
41
|
+
stdout.puts "Cannot build record: #{record_body}"
|
44
42
|
end
|
45
43
|
end.compact
|
46
44
|
end
|
@@ -22,13 +22,11 @@ module RecordStore
|
|
22
22
|
|
23
23
|
# Unroll each record set into multiple records
|
24
24
|
record_set.data.map do |record|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
stdout.puts "Cannot build record: #{record}"
|
31
|
-
end
|
25
|
+
record_set_member = record_set.dup
|
26
|
+
record_set_member.data = [record]
|
27
|
+
build_from_api(record_set_member)
|
28
|
+
rescue StandardError
|
29
|
+
stdout.puts "Cannot build record: #{record}"
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -44,12 +42,10 @@ module RecordStore
|
|
44
42
|
private
|
45
43
|
|
46
44
|
def session
|
47
|
-
@dns ||=
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
)
|
52
|
-
end
|
45
|
+
@dns ||= Google::Cloud::Dns.new(
|
46
|
+
project_id: secrets.fetch('project_id'),
|
47
|
+
credentials: Google::Cloud::Dns::Credentials.new(secrets),
|
48
|
+
)
|
53
49
|
end
|
54
50
|
|
55
51
|
def secrets
|
@@ -50,7 +50,7 @@ module RecordStore
|
|
50
50
|
# Downloads all the records from the provider.
|
51
51
|
#
|
52
52
|
# Returns: an array of `Record` for each record in the provider's zone
|
53
|
-
def retrieve_current_records(zone:, stdout: $stdout)
|
53
|
+
def retrieve_current_records(zone:, stdout: $stdout)
|
54
54
|
records_for_zone(zone)
|
55
55
|
.flat_map { |short_record| build_from_api(short_record) }
|
56
56
|
.compact
|
@@ -3,6 +3,7 @@ require 'resolv'
|
|
3
3
|
module RecordStore
|
4
4
|
class Provider
|
5
5
|
class Error < StandardError; end
|
6
|
+
|
6
7
|
class UnparseableBodyError < Error; end
|
7
8
|
|
8
9
|
class << self
|
@@ -152,24 +153,22 @@ module RecordStore
|
|
152
153
|
)
|
153
154
|
|
154
155
|
loop do
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
waiter.wait
|
172
|
-
end
|
156
|
+
return yield
|
157
|
+
rescue UnparseableBodyError
|
158
|
+
raise if max_retries <= 0
|
159
|
+
max_retries -= 1
|
160
|
+
|
161
|
+
waiter.wait(message: 'Waiting to retry after receiving an unparseable response')
|
162
|
+
rescue Net::OpenTimeout, Errno::ETIMEDOUT
|
163
|
+
raise if max_timeouts <= 0
|
164
|
+
max_timeouts -= 1
|
165
|
+
|
166
|
+
$stderr.puts('Retrying after a connection timeout')
|
167
|
+
rescue Errno::ECONNRESET
|
168
|
+
raise if max_conn_resets <= 0
|
169
|
+
max_conn_resets -= 1
|
170
|
+
|
171
|
+
waiter.wait
|
173
172
|
end
|
174
173
|
end
|
175
174
|
end
|
data/lib/record_store/version.rb
CHANGED
@@ -32,8 +32,8 @@ module RecordStore
|
|
32
32
|
filters_for_records_to_exclude = template_file_yaml[:except_record] || []
|
33
33
|
|
34
34
|
new(template: ERB.new(template_file),
|
35
|
-
|
36
|
-
|
35
|
+
filters_for_records_to_template: filters_for_records_to_template,
|
36
|
+
filters_for_records_to_exclude: filters_for_records_to_exclude)
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
@@ -31,7 +31,7 @@ module RecordStore
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def write(name, config:, records:, format: :file)
|
34
|
-
raise ArgumentError, "format must be :directory or :file" unless
|
34
|
+
raise ArgumentError, "format must be :directory or :file" unless [:file, :directory].include?(format)
|
35
35
|
name = name.chomp('.')
|
36
36
|
zone_file = "#{RecordStore.zones_path}/#{name}.yml"
|
37
37
|
zone = { name => { config: config.to_hash } }
|
data/lib/record_store/zone.rb
CHANGED
@@ -53,7 +53,7 @@ module RecordStore
|
|
53
53
|
(ENV['RECORD_STORE_MAX_THREADS'] || DEFAULT_MAX_PARALLEL_THREADS).to_i
|
54
54
|
end
|
55
55
|
|
56
|
-
def modified(verbose: false)
|
56
|
+
def modified(verbose: false)
|
57
57
|
modified_zones = []
|
58
58
|
mutex = Mutex.new
|
59
59
|
zones = all
|
@@ -85,10 +85,8 @@ module RecordStore
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def build_changesets(all: false)
|
88
|
-
@changesets ||=
|
89
|
-
|
90
|
-
Changeset.build_from(provider: provider, zone: self, all: all)
|
91
|
-
end
|
88
|
+
@changesets ||= providers.map do |provider|
|
89
|
+
Changeset.build_from(provider: provider, zone: self, all: all)
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
data/lib/record_store.rb
CHANGED
@@ -53,7 +53,7 @@ module RecordStore
|
|
53
53
|
def zones_path
|
54
54
|
@zones_path ||= Pathname.new(
|
55
55
|
File.expand_path(config.fetch('zones_path'),
|
56
|
-
|
56
|
+
File.dirname(config_path)),
|
57
57
|
).realpath.to_s
|
58
58
|
end
|
59
59
|
|
@@ -64,7 +64,7 @@ module RecordStore
|
|
64
64
|
def implicit_records_templates_path
|
65
65
|
@implicit_records_templates_path ||= Pathname.new(
|
66
66
|
File.expand_path(config.fetch('implicit_records_templates_path'),
|
67
|
-
|
67
|
+
File.dirname(config_path)),
|
68
68
|
).realpath.to_s
|
69
69
|
end
|
70
70
|
|
data/record_store.gemspec
CHANGED
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_development_dependency 'vcr'
|
49
49
|
spec.add_development_dependency 'pry'
|
50
50
|
spec.add_development_dependency 'webmock'
|
51
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
51
|
+
spec.add_development_dependency 'rubocop', '~> 1.18.0'
|
52
|
+
spec.add_development_dependency 'rubocop-shopify', '~> 2.2.0'
|
52
53
|
spec.add_development_dependency 'minitest-focus'
|
53
54
|
end
|
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: 6.5.
|
4
|
+
version: 6.5.5
|
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: 2021-
|
12
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -303,14 +303,28 @@ dependencies:
|
|
303
303
|
requirements:
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
|
-
version: 1.
|
306
|
+
version: 1.18.0
|
307
307
|
type: :development
|
308
308
|
prerelease: false
|
309
309
|
version_requirements: !ruby/object:Gem::Requirement
|
310
310
|
requirements:
|
311
311
|
- - "~>"
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version: 1.
|
313
|
+
version: 1.18.0
|
314
|
+
- !ruby/object:Gem::Dependency
|
315
|
+
name: rubocop-shopify
|
316
|
+
requirement: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - "~>"
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: 2.2.0
|
321
|
+
type: :development
|
322
|
+
prerelease: false
|
323
|
+
version_requirements: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - "~>"
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: 2.2.0
|
314
328
|
- !ruby/object:Gem::Dependency
|
315
329
|
name: minitest-focus
|
316
330
|
requirement: !ruby/object:Gem::Requirement
|
@@ -357,6 +371,7 @@ files:
|
|
357
371
|
- lib/record_store/provider.rb
|
358
372
|
- lib/record_store/provider/dnsimple.rb
|
359
373
|
- lib/record_store/provider/dnsimple/patch_api_header.rb
|
374
|
+
- lib/record_store/provider/dnsimple/patch_request_error_to_include_errors.rb
|
360
375
|
- lib/record_store/provider/dynect.rb
|
361
376
|
- lib/record_store/provider/google_cloud_dns.rb
|
362
377
|
- lib/record_store/provider/ns1.rb
|