record_store 6.5.3 → 6.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +26 -5
- data/CHANGELOG.md +6 -0
- data/lib/record_store/cli.rb +7 -9
- 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 +6 -5
- data/lib/record_store/zone/yaml_definitions.rb +1 -1
- data/lib/record_store/zone.rb +4 -6
- data/lib/record_store.rb +2 -2
- data/record_store.gemspec +3 -2
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a988dc5071a5cba7b77105bfbd6a6a3bd85c7049faabccf84be00ceb4ea0cd
|
4
|
+
data.tar.gz: 980159cf5899746871435d7b8674d94c4143bd8c0d1f8fe3b43c5cb61e03a360
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be5a4503a83bca9e0f8c50fedfe7da0e8ed53cf99e40dd375d2b547df0ef740ca8e8138fd64cea3c4247230d3e7fb874824a908554976f0a3e62045d718a7ee
|
7
|
+
data.tar.gz: 0f10f66dc76a7a86cce97cb05fb50c977db2fa163fe8dc735b5dc108d0825feb5bfc6639c5aaa581f7edc829a8023e9cdb437e75619118e4bf52fde1c59bec3e
|
data/.github/workflows/ci.yml
CHANGED
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
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 6.5.5
|
4
|
+
- Include DNSimple validation error details in exceptions
|
5
|
+
|
6
|
+
## 6.5.4
|
7
|
+
- Updates config path structure for build pipeline
|
8
|
+
|
3
9
|
## 6.5.3
|
4
10
|
- Adds check for detecting shadowed records, used when a record being added to a zone in record-store will have no effect because it is shadowed by another record.
|
5
11
|
|
data/lib/record_store/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module RecordStore
|
|
7
7
|
|
8
8
|
def initialize(*args)
|
9
9
|
super
|
10
|
-
RecordStore.config_path = options.fetch('config', "#{Dir.pwd}/
|
10
|
+
RecordStore.config_path = options.fetch('config', "#{Dir.pwd}/config.yml")
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.exit_on_failure?
|
@@ -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
@@ -27,13 +27,13 @@ module RecordStore
|
|
27
27
|
filepath = template_filepath_for(filename: filename)
|
28
28
|
template_file = File.read(filepath)
|
29
29
|
|
30
|
-
template_file_yaml = YAML.
|
30
|
+
template_file_yaml = YAML.safe_load(template_file, permitted_classes: [Regexp]).deep_symbolize_keys
|
31
31
|
filters_for_records_to_template = template_file_yaml[:each_record]
|
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
|
@@ -96,8 +96,9 @@ module RecordStore
|
|
96
96
|
def template_record_for(record:, current_records:)
|
97
97
|
context = TemplateContext.build(record: record, current_records: current_records)
|
98
98
|
|
99
|
-
YAML.
|
100
|
-
template.result(context.fetch_binding)
|
99
|
+
YAML.safe_load(
|
100
|
+
template.result(context.fetch_binding),
|
101
|
+
permitted_classes: [Regexp],
|
101
102
|
).deep_symbolize_keys
|
102
103
|
end
|
103
104
|
end
|
@@ -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
|
@@ -79,16 +79,14 @@ module RecordStore
|
|
79
79
|
|
80
80
|
def initialize(name:, records: [], config: {}, abstract_syntax_trees: {})
|
81
81
|
@name = Record.ensure_ends_with_dot(name)
|
82
|
-
@config = RecordStore::Zone::Config.new(config.deep_symbolize_keys)
|
82
|
+
@config = RecordStore::Zone::Config.new(**config.deep_symbolize_keys)
|
83
83
|
@records = build_records(records)
|
84
84
|
@abstract_syntax_trees = abstract_syntax_trees
|
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
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_runtime_dependency 'google-cloud-dns', '~> 0.31.0'
|
40
40
|
spec.add_runtime_dependency 'ruby-limiter', '~> 1.0', '>= 1.0.1'
|
41
41
|
spec.add_runtime_dependency 'ns1'
|
42
|
-
spec.add_runtime_dependency 'oci', '~> 2.
|
42
|
+
spec.add_runtime_dependency 'oci', '~> 2.14.0'
|
43
43
|
|
44
44
|
spec.add_development_dependency 'byebug'
|
45
45
|
spec.add_development_dependency 'rake'
|
@@ -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.8
|
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:
|
12
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -191,14 +191,14 @@ dependencies:
|
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 2.
|
194
|
+
version: 2.14.0
|
195
195
|
type: :runtime
|
196
196
|
prerelease: false
|
197
197
|
version_requirements: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 2.
|
201
|
+
version: 2.14.0
|
202
202
|
- !ruby/object:Gem::Dependency
|
203
203
|
name: byebug
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|