record_store 8.0.0 → 8.0.2

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: 6e518dfc9c19dd1015387da818e7771977370cd0d4bf461eda200d378978b29e
4
+ data.tar.gz: f056671c6d1f39a9b0a12a0574be13fe4adb152a9dbcf90015a4642bb241e4ea
5
5
  SHA512:
6
- metadata.gz: 62c5ac81796346237199606dbf041a3186ba20d59a3d6e0910548f1e0a5f2ac14fe4b1cdbe8be99c85422c533209b094d8eb14d2d156b661a19f40f5787f0098
7
- data.tar.gz: 216ded77496c797639e54305d23136a867b2709919fbe38fe78c9d28ccf4557aeaf22b2ecb773ca135f0ea079c5caa8e63d1f613dbc564fa9453ff9427942656
6
+ metadata.gz: 95ac97176d1adc48e315db207c32aa1e1c394906e0b3026cac517ee43f130fcedd3d62003a08cbcfb387e36844aa5bdb580797588370278829002e0c3b952976
7
+ data.tar.gz: d6c9176b3a0a85e7a34076a04a226f9e4311b23ec6c32f569c69d6a460b0f75a3e5bc8f69b6a637781d5f6ca4950270ce0338adba73c742a5f0dda18f558113a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 8.0.2
4
+ - Fix Changesets to be case-insensitive
5
+
6
+ ## 8.0.1
7
+ - Fix Cloudflare provider to handle paginated returns from API
8
+
3
9
  ## 8.0.0
4
10
  - Remove api_fqdn from Cloudflare provider config
5
11
 
@@ -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
- 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.2'.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.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-10-23 00:00:00.000000000 Z
12
+ date: 2024-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel