record_store 8.0.0 → 8.0.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e518dfc9c19dd1015387da818e7771977370cd0d4bf461eda200d378978b29e
|
4
|
+
data.tar.gz: f056671c6d1f39a9b0a12a0574be13fe4adb152a9dbcf90015a4642bb241e4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ac97176d1adc48e315db207c32aa1e1c394906e0b3026cac517ee43f130fcedd3d62003a08cbcfb387e36844aa5bdb580797588370278829002e0c3b952976
|
7
|
+
data.tar.gz: d6c9176b3a0a85e7a34076a04a226f9e4311b23ec6c32f569c69d6a460b0f75a3e5bc8f69b6a637781d5f6ca4950270ce0338adba73c742a5f0dda18f558113a
|
data/CHANGELOG.md
CHANGED
@@ -55,8 +55,8 @@ module RecordStore
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def initialize(current_records: [], desired_records: [], provider:, zone:)
|
58
|
-
@current_records = Set.new(current_records)
|
59
|
-
@desired_records = Set.new(desired_records)
|
58
|
+
@current_records = Set.new(normalize_records(current_records))
|
59
|
+
@desired_records = Set.new(normalize_records(desired_records))
|
60
60
|
@provider = provider
|
61
61
|
@zone = zone
|
62
62
|
|
@@ -114,5 +114,18 @@ module RecordStore
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
|
+
|
118
|
+
def normalize_records(records)
|
119
|
+
records.map do |record|
|
120
|
+
record.dup.tap do |r|
|
121
|
+
r.fqdn = r.fqdn.downcase
|
122
|
+
r.rdata.each do |key, value|
|
123
|
+
next if key == :txtdata
|
124
|
+
|
125
|
+
r.send("#{key}=", value.downcase) if value.is_a?(String)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
117
130
|
end
|
118
131
|
end
|
@@ -27,6 +27,14 @@ module Cloudflare
|
|
27
27
|
result
|
28
28
|
end
|
29
29
|
|
30
|
+
def result_info_raw
|
31
|
+
result_info_raw = json['result_info']
|
32
|
+
|
33
|
+
return if result_info_raw.nil? || result_info_raw.empty? || !success
|
34
|
+
|
35
|
+
result_info_raw
|
36
|
+
end
|
37
|
+
|
30
38
|
def success
|
31
39
|
json['success']
|
32
40
|
end
|
@@ -20,20 +20,50 @@ module RecordStore
|
|
20
20
|
def retrieve_current_records(zone:, stdout: $stdout)
|
21
21
|
zone_id = zone_name_to_id(zone)
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
all_records = []
|
24
|
+
page = 1
|
25
|
+
per_page = 1000
|
26
|
+
|
27
|
+
loop do
|
28
|
+
response = nil
|
29
|
+
retry_on_connection_errors do
|
30
|
+
response = client.get("/client/v4/zones/#{zone_id}/dns_records", page: page, per_page: per_page)
|
31
|
+
end
|
32
|
+
|
33
|
+
records = response.result_raw || []
|
34
|
+
all_records.concat(records)
|
35
|
+
|
36
|
+
break if page * per_page >= response.result_info_raw['total_count']
|
37
|
+
|
38
|
+
page += 1
|
26
39
|
end
|
40
|
+
|
41
|
+
all_records.map { |api_body| build_from_api(api_body) }
|
27
42
|
end
|
28
43
|
|
29
44
|
# Returns an array of the zones managed by provider as strings
|
30
45
|
# Cloudflare returns zones across all accounts accessible by the API token
|
31
46
|
# Can implement filtering in request if needed
|
32
47
|
def zones
|
33
|
-
|
34
|
-
|
35
|
-
|
48
|
+
all_zones = []
|
49
|
+
page = 1
|
50
|
+
per_page = 50
|
51
|
+
|
52
|
+
loop do
|
53
|
+
response = nil
|
54
|
+
retry_on_connection_errors do
|
55
|
+
response = client.get('/client/v4/zones', page: page, per_page: per_page)
|
56
|
+
end
|
57
|
+
|
58
|
+
zones = response.result_raw || []
|
59
|
+
all_zones.concat(zones)
|
60
|
+
|
61
|
+
break if page * per_page >= response.result_info_raw['total_count']
|
62
|
+
|
63
|
+
page += 1
|
36
64
|
end
|
65
|
+
|
66
|
+
all_zones.map { |zone| zone['name'] }
|
37
67
|
end
|
38
68
|
|
39
69
|
def apply_changeset(changeset, stdout = $stdout)
|
@@ -173,7 +203,8 @@ module RecordStore
|
|
173
203
|
|
174
204
|
def zone_name_to_id(zone_name)
|
175
205
|
retry_on_connection_errors do
|
176
|
-
|
206
|
+
params = { name: zone_name }
|
207
|
+
matching_zones = client.get("/client/v4/zones", params).result_raw
|
177
208
|
|
178
209
|
case matching_zones.size
|
179
210
|
when 0
|
data/lib/record_store/version.rb
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: 8.0.
|
4
|
+
version: 8.0.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: 2024-
|
12
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|