record_store 8.0.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 773a737dfea1f6ce9646d4b7f8df8358e85b1cf1438f2240ef5609665067dfa6
4
- data.tar.gz: 8c0cd658784c649b77b6a19df3b7ec4661ad63aeaf5c17dddb5c8166a2c422a0
3
+ metadata.gz: 7680653d3944e3a5c8de1a31055e38266a379d4caed36f7eb30bb5ae27217d71
4
+ data.tar.gz: 5487a8cbcd8079815fbe3e0276e99360a16d954b02b6ed819639bd73e016bc5e
5
5
  SHA512:
6
- metadata.gz: 62c5ac81796346237199606dbf041a3186ba20d59a3d6e0910548f1e0a5f2ac14fe4b1cdbe8be99c85422c533209b094d8eb14d2d156b661a19f40f5787f0098
7
- data.tar.gz: 216ded77496c797639e54305d23136a867b2709919fbe38fe78c9d28ccf4557aeaf22b2ecb773ca135f0ea079c5caa8e63d1f613dbc564fa9453ff9427942656
6
+ metadata.gz: 0ba282fe4046bf7169648d3eecb0137fefd8882dc4c7dbf3c5af0f17cf0ef56ba948d0235668057656c53c709f9372ee155e6aa3aab211c265fdc322e1d9c4ba
7
+ data.tar.gz: f4e9646af425cdbe7a6827f0fd88e8c24717c6ea21921228ab72164a7e1b019071533f2576ba25b77bf02e3477a22e2d00d0a4df0d1cbfb985e6137c562dd1f1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 8.0.1
4
+ - Fix Cloudflare provider to handle paginated returns from API
5
+
3
6
  ## 8.0.0
4
7
  - Remove api_fqdn from Cloudflare provider config
5
8
 
@@ -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
- retry_on_connection_errors do
24
- records = client.get("/client/v4/zones/#{zone_id}/dns_records").result_raw || []
25
- records.map { |api_body| build_from_api(api_body) }
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
- retry_on_connection_errors do
34
- zones = client.get('/client/v4/zones').result_raw || []
35
- zones.map { |zone| zone['name'] }
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
- matching_zones = client.get('/client/v4/zones').result_raw.select { |zone| zone['name'] == zone_name }
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
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '8.0.0'.freeze
2
+ VERSION = '8.0.1'.freeze
3
3
  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: 8.0.0
4
+ version: 8.0.1
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-10-23 00:00:00.000000000 Z
12
+ date: 2024-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel