record_store 5.7.1 → 5.7.2
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 +4 -4
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +15 -15
- data/lib/record_store/provider/ns1.rb +71 -29
- data/lib/record_store/version.rb +1 -1
- data/record_store.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d36a7207b563630aaad6b46c14ea53bcd101ecab97a080626c5f352e52820af
|
4
|
+
data.tar.gz: 91c4744ccf18f391f82fccf47663d4706222944029131a9a0d00d42c37360a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a34d35d02f00de085fe658ec928b8407f5470a4ab3e1679957de94bf3311bbb289eec0a2cb2281a1309565011a8522159abeeeb924237b55db8c0a7d7e3f982
|
7
|
+
data.tar.gz: '09f3ae5443ef6a06ac977002c79fbc6e37f8c8524bc310a3e4e43b954c8446de1a2dca18c673a33be727156669a00bb19789f0bfef1fe4341f2114f56d0b5697'
|
@@ -20,7 +20,7 @@ Style/Alias:
|
|
20
20
|
- prefer_alias
|
21
21
|
- prefer_alias_method
|
22
22
|
|
23
|
-
Layout/
|
23
|
+
Layout/HashAlignment:
|
24
24
|
EnforcedHashRocketStyle: key
|
25
25
|
EnforcedColonStyle: key
|
26
26
|
EnforcedLastArgumentHashStyle: ignore_implicit
|
@@ -30,7 +30,7 @@ Layout/AlignHash:
|
|
30
30
|
- ignore_implicit
|
31
31
|
- ignore_explicit
|
32
32
|
|
33
|
-
Layout/
|
33
|
+
Layout/ParameterAlignment:
|
34
34
|
EnforcedStyle: with_fixed_indentation
|
35
35
|
SupportedStyles:
|
36
36
|
- with_first_parameter
|
@@ -172,7 +172,7 @@ Naming/FileName:
|
|
172
172
|
Regex:
|
173
173
|
IgnoreExecutableScripts: true
|
174
174
|
|
175
|
-
Layout/
|
175
|
+
Layout/FirstArgumentIndentation:
|
176
176
|
EnforcedStyle: consistent
|
177
177
|
SupportedStyles:
|
178
178
|
- consistent
|
@@ -225,7 +225,7 @@ Layout/IndentationConsistency:
|
|
225
225
|
Layout/IndentationWidth:
|
226
226
|
Width: 2
|
227
227
|
|
228
|
-
Layout/
|
228
|
+
Layout/FirstArrayElementIndentation:
|
229
229
|
EnforcedStyle: consistent
|
230
230
|
SupportedStyles:
|
231
231
|
- special_inside_parentheses
|
@@ -233,10 +233,10 @@ Layout/IndentFirstArrayElement:
|
|
233
233
|
- align_brackets
|
234
234
|
IndentationWidth:
|
235
235
|
|
236
|
-
Layout/
|
236
|
+
Layout/AssignmentIndentation:
|
237
237
|
IndentationWidth:
|
238
238
|
|
239
|
-
Layout/
|
239
|
+
Layout/FirstHashElementIndentation:
|
240
240
|
EnforcedStyle: consistent
|
241
241
|
SupportedStyles:
|
242
242
|
- special_inside_parentheses
|
@@ -340,9 +340,9 @@ Style/PercentQLiterals:
|
|
340
340
|
Naming/PredicateName:
|
341
341
|
NamePrefix:
|
342
342
|
- is_
|
343
|
-
|
343
|
+
ForbiddenPrefixes:
|
344
344
|
- is_
|
345
|
-
|
345
|
+
AllowedMethods:
|
346
346
|
- is_a?
|
347
347
|
Exclude:
|
348
348
|
- 'spec/**/*'
|
@@ -467,7 +467,7 @@ Style/TernaryParentheses:
|
|
467
467
|
- require_no_parentheses
|
468
468
|
AllowSafeAssignment: true
|
469
469
|
|
470
|
-
Layout/
|
470
|
+
Layout/TrailingEmptyLines:
|
471
471
|
EnforcedStyle: final_newline
|
472
472
|
SupportedStyles:
|
473
473
|
- final_newline
|
@@ -478,7 +478,7 @@ Style/TrivialAccessors:
|
|
478
478
|
AllowPredicates: true
|
479
479
|
AllowDSLWriters: false
|
480
480
|
IgnoreClassMethods: false
|
481
|
-
|
481
|
+
AllowedMethod:
|
482
482
|
- to_ary
|
483
483
|
- to_a
|
484
484
|
- to_c
|
@@ -561,7 +561,7 @@ Lint/UnusedMethodArgument:
|
|
561
561
|
Naming/AccessorMethodName:
|
562
562
|
Enabled: true
|
563
563
|
|
564
|
-
Layout/
|
564
|
+
Layout/ArrayAlignment:
|
565
565
|
Enabled: true
|
566
566
|
|
567
567
|
Style/ArrayJoin:
|
@@ -840,7 +840,7 @@ Style/WhileUntilDo:
|
|
840
840
|
Style/ZeroLengthPredicate:
|
841
841
|
Enabled: true
|
842
842
|
|
843
|
-
Layout/
|
843
|
+
Layout/HeredocIndentation:
|
844
844
|
EnforcedStyle: squiggly
|
845
845
|
|
846
846
|
Lint/AmbiguousOperator:
|
@@ -864,7 +864,7 @@ Lint/DeprecatedClassMethods:
|
|
864
864
|
Lint/DuplicateMethods:
|
865
865
|
Enabled: true
|
866
866
|
|
867
|
-
Lint/
|
867
|
+
Lint/DuplicateHashKey:
|
868
868
|
Enabled: true
|
869
869
|
|
870
870
|
Lint/EachWithObjectArgument:
|
@@ -891,7 +891,7 @@ Lint/FloatOutOfRange:
|
|
891
891
|
Lint/FormatParameterMismatch:
|
892
892
|
Enabled: true
|
893
893
|
|
894
|
-
Lint/
|
894
|
+
Lint/SuppressedException:
|
895
895
|
AllowComments: true
|
896
896
|
|
897
897
|
Lint/ImplicitStringConcatenation:
|
@@ -947,7 +947,7 @@ Lint/ShadowedException:
|
|
947
947
|
Lint/ShadowingOuterLocalVariable:
|
948
948
|
Enabled: true
|
949
949
|
|
950
|
-
Lint/
|
950
|
+
Lint/RedundantStringCoercion:
|
951
951
|
Enabled: true
|
952
952
|
|
953
953
|
Lint/UnderscorePrefixedVariableName:
|
@@ -5,6 +5,41 @@ module RecordStore
|
|
5
5
|
class Provider::NS1 < Provider
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
|
+
class ApiAnswer
|
9
|
+
class << self
|
10
|
+
def from_full_api_answer(type:, record_id:, answer:)
|
11
|
+
ApiAnswer.new(type: type, record_id: record_id, rrdata: answer['answer'])
|
12
|
+
end
|
13
|
+
|
14
|
+
def from_short_api_answer(type:, record_id:, answer:)
|
15
|
+
rrdata_fields = case type
|
16
|
+
when 'SPF', 'TXT'
|
17
|
+
[answer]
|
18
|
+
else
|
19
|
+
answer.split
|
20
|
+
end
|
21
|
+
|
22
|
+
ApiAnswer.new(type: type, record_id: record_id, rrdata: rrdata_fields)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :type, :record_id, :rrdata
|
27
|
+
|
28
|
+
def initialize(type:, record_id:, rrdata:)
|
29
|
+
@type = type
|
30
|
+
@record_id = record_id
|
31
|
+
@rrdata = rrdata
|
32
|
+
end
|
33
|
+
|
34
|
+
def rrdata_string
|
35
|
+
rrdata.join(' ')
|
36
|
+
end
|
37
|
+
|
38
|
+
def id
|
39
|
+
[record_id, type, *rrdata]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
8
43
|
class << self
|
9
44
|
def client
|
10
45
|
Provider::NS1::Client.new(api_key: secrets['api_key'])
|
@@ -14,16 +49,9 @@ module RecordStore
|
|
14
49
|
#
|
15
50
|
# Returns: an array of `Record` for each record in the provider's zone
|
16
51
|
def retrieve_current_records(zone:, stdout: $stdout) # rubocop:disable Lint/UnusedMethodArgument
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
fqdn: short_record["domain"],
|
21
|
-
type: short_record["type"],
|
22
|
-
must_exist: true,
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
full_api_records.map { |r| build_from_api(r) }.flatten.compact
|
52
|
+
records_for_zone(zone)
|
53
|
+
.flat_map { |short_record| build_from_api(short_record) }
|
54
|
+
.compact
|
27
55
|
end
|
28
56
|
|
29
57
|
# Returns an array of the zones managed by provider as strings
|
@@ -35,7 +63,7 @@ module RecordStore
|
|
35
63
|
|
36
64
|
# Fetches simplified records for the provided zone
|
37
65
|
def records_for_zone(zone)
|
38
|
-
client.zone(zone)[
|
66
|
+
client.zone(zone)['records']
|
39
67
|
end
|
40
68
|
|
41
69
|
# Creates a new record to the zone. It is expected this call modifies external state.
|
@@ -124,10 +152,17 @@ module RecordStore
|
|
124
152
|
|
125
153
|
# Identify the answer in this record with the matching ID, and update it
|
126
154
|
updated = false
|
127
|
-
existing_record[
|
128
|
-
|
155
|
+
existing_record['answers'].each do |existing_answer|
|
156
|
+
existing_answer_id = ApiAnswer.from_full_api_answer(
|
157
|
+
record_id: existing_record['id'],
|
158
|
+
type: existing_record['type'],
|
159
|
+
answer: existing_answer,
|
160
|
+
).id
|
161
|
+
|
162
|
+
next if existing_answer_id != id
|
163
|
+
|
129
164
|
updated = true
|
130
|
-
|
165
|
+
existing_answer['answer'] = build_api_answer_from_record(record)
|
131
166
|
end
|
132
167
|
|
133
168
|
unless updated
|
@@ -140,31 +175,38 @@ module RecordStore
|
|
140
175
|
zone: zone,
|
141
176
|
fqdn: record_fqdn,
|
142
177
|
type: record.type,
|
143
|
-
params: { answers: existing_record[
|
178
|
+
params: { answers: existing_record['answers'], ttl: record.ttl }
|
144
179
|
)
|
145
180
|
end
|
146
181
|
|
147
182
|
def build_from_api(api_record)
|
148
|
-
fqdn = Record.ensure_ends_with_dot(api_record[
|
183
|
+
fqdn = Record.ensure_ends_with_dot(api_record['domain'])
|
149
184
|
|
150
|
-
record_type = api_record[
|
185
|
+
record_type = api_record['type']
|
151
186
|
return if record_type == 'SOA'
|
152
187
|
|
153
|
-
api_record[
|
154
|
-
|
188
|
+
answers = api_record['short_answers'].map do |raw_answer|
|
189
|
+
ApiAnswer.from_short_api_answer(
|
190
|
+
record_id: api_record['id'],
|
191
|
+
type: api_record['type'],
|
192
|
+
answer: raw_answer,
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
answers.map do |answer|
|
155
197
|
record = {
|
156
|
-
ttl: api_record[
|
198
|
+
ttl: api_record['ttl'],
|
157
199
|
fqdn: fqdn.downcase,
|
158
|
-
record_id:
|
200
|
+
record_id: answer.id,
|
159
201
|
}
|
160
202
|
|
161
203
|
case record_type
|
162
204
|
when 'A', 'AAAA'
|
163
|
-
record.merge!(address: answer.
|
205
|
+
record.merge!(address: answer.rrdata_string)
|
164
206
|
when 'ALIAS'
|
165
|
-
record.merge!(alias: answer.
|
207
|
+
record.merge!(alias: answer.rrdata_string)
|
166
208
|
when 'CAA'
|
167
|
-
flags, tag, value = answer
|
209
|
+
flags, tag, value = answer.rrdata
|
168
210
|
|
169
211
|
record.merge!(
|
170
212
|
flags: flags.to_i,
|
@@ -172,21 +214,21 @@ module RecordStore
|
|
172
214
|
value: Record.unquote(value),
|
173
215
|
)
|
174
216
|
when 'CNAME'
|
175
|
-
record.merge!(cname: answer.
|
217
|
+
record.merge!(cname: answer.rrdata_string)
|
176
218
|
when 'MX'
|
177
219
|
|
178
|
-
preference, exchange = answer
|
220
|
+
preference, exchange = answer.rrdata
|
179
221
|
|
180
222
|
record.merge!(
|
181
223
|
preference: preference.to_i,
|
182
224
|
exchange: exchange,
|
183
225
|
)
|
184
226
|
when 'NS'
|
185
|
-
record.merge!(nsdname: answer.
|
227
|
+
record.merge!(nsdname: answer.rrdata_string)
|
186
228
|
when 'SPF', 'TXT'
|
187
|
-
record.merge!(txtdata: Record.unlong_quote(Record.unescape(answer.
|
229
|
+
record.merge!(txtdata: Record.unlong_quote(Record.unescape(answer.rrdata_string).gsub(';', '\;')))
|
188
230
|
when 'SRV'
|
189
|
-
priority, weight, port, host = answer
|
231
|
+
priority, weight, port, host = answer.rrdata
|
190
232
|
|
191
233
|
record.merge!(
|
192
234
|
priority: priority.to_i,
|
data/lib/record_store/version.rb
CHANGED
data/record_store.gemspec
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.7.
|
4
|
+
version: 5.7.2
|
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: 2019-
|
12
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -311,6 +311,20 @@ dependencies:
|
|
311
311
|
- - ">="
|
312
312
|
- !ruby/object:Gem::Version
|
313
313
|
version: '0'
|
314
|
+
- !ruby/object:Gem::Dependency
|
315
|
+
name: minitest-focus
|
316
|
+
requirement: !ruby/object:Gem::Requirement
|
317
|
+
requirements:
|
318
|
+
- - ">="
|
319
|
+
- !ruby/object:Gem::Version
|
320
|
+
version: '0'
|
321
|
+
type: :development
|
322
|
+
prerelease: false
|
323
|
+
version_requirements: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - ">="
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '0'
|
314
328
|
description: Manage DNS through a git-based workflow. If you're looking for the original
|
315
329
|
'record_store', that has been renamed to 'sequel_record_store'.
|
316
330
|
email:
|