@@ -28,11 +28,11 @@ import (
28
28
"strconv"
29
29
"strings"
30
30
31
- "github.com/cloudflare/cloudflare-go"
32
- cloudflarev4 "github.com/cloudflare/cloudflare-go/v4 "
33
- "github.com/cloudflare/cloudflare-go/v4 /addressing"
34
- "github.com/cloudflare/cloudflare-go/v4 /option"
35
- "github.com/cloudflare/cloudflare-go/v4 /zones"
31
+ cloudflarev0 "github.com/cloudflare/cloudflare-go"
32
+ "github.com/cloudflare/cloudflare-go/v5 "
33
+ "github.com/cloudflare/cloudflare-go/v5 /addressing"
34
+ "github.com/cloudflare/cloudflare-go/v5 /option"
35
+ "github.com/cloudflare/cloudflare-go/v5 /zones"
36
36
log "github.com/sirupsen/logrus"
37
37
"golang.org/x/net/publicsuffix"
38
38
@@ -75,14 +75,14 @@ type DNSRecordIndex struct {
75
75
Content string
76
76
}
77
77
78
- type DNSRecordsMap map [DNSRecordIndex ]cloudflare .DNSRecord
78
+ type DNSRecordsMap map [DNSRecordIndex ]cloudflarev0 .DNSRecord
79
79
80
80
// for faster getCustomHostname() lookup
81
81
type CustomHostnameIndex struct {
82
82
Hostname string
83
83
}
84
84
85
- type CustomHostnamesMap map [CustomHostnameIndex ]cloudflare .CustomHostname
85
+ type CustomHostnamesMap map [CustomHostnameIndex ]cloudflarev0 .CustomHostname
86
86
87
87
var recordTypeProxyNotSupported = map [string ]bool {
88
88
"LOC" : true ,
@@ -109,28 +109,28 @@ type cloudFlareDNS interface {
109
109
ZoneIDByName (zoneName string ) (string , error )
110
110
ListZones (ctx context.Context , params zones.ZoneListParams ) autoPager [zones.Zone ]
111
111
GetZone (ctx context.Context , zoneID string ) (* zones.Zone , error )
112
- ListDNSRecords (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .ListDNSRecordsParams ) ([]cloudflare .DNSRecord , * cloudflare .ResultInfo , error )
113
- CreateDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .CreateDNSRecordParams ) (cloudflare .DNSRecord , error )
114
- DeleteDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , recordID string ) error
115
- UpdateDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .UpdateDNSRecordParams ) error
112
+ ListDNSRecords (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .ListDNSRecordsParams ) ([]cloudflarev0 .DNSRecord , * cloudflarev0 .ResultInfo , error )
113
+ CreateDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .CreateDNSRecordParams ) (cloudflarev0 .DNSRecord , error )
114
+ DeleteDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , recordID string ) error
115
+ UpdateDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .UpdateDNSRecordParams ) error
116
116
ListDataLocalizationRegionalHostnames (ctx context.Context , params addressing.RegionalHostnameListParams ) autoPager [addressing.RegionalHostnameListResponse ]
117
117
CreateDataLocalizationRegionalHostname (ctx context.Context , params addressing.RegionalHostnameNewParams ) error
118
118
UpdateDataLocalizationRegionalHostname (ctx context.Context , hostname string , params addressing.RegionalHostnameEditParams ) error
119
119
DeleteDataLocalizationRegionalHostname (ctx context.Context , hostname string , params addressing.RegionalHostnameDeleteParams ) error
120
- CustomHostnames (ctx context.Context , zoneID string , page int , filter cloudflare .CustomHostname ) ([]cloudflare .CustomHostname , cloudflare .ResultInfo , error )
120
+ CustomHostnames (ctx context.Context , zoneID string , page int , filter cloudflarev0 .CustomHostname ) ([]cloudflarev0 .CustomHostname , cloudflarev0 .ResultInfo , error )
121
121
DeleteCustomHostname (ctx context.Context , zoneID string , customHostnameID string ) error
122
- CreateCustomHostname (ctx context.Context , zoneID string , ch cloudflare .CustomHostname ) (* cloudflare .CustomHostnameResponse , error )
122
+ CreateCustomHostname (ctx context.Context , zoneID string , ch cloudflarev0 .CustomHostname ) (* cloudflarev0 .CustomHostnameResponse , error )
123
123
}
124
124
125
125
type zoneService struct {
126
- service * cloudflare .API
127
- serviceV4 * cloudflarev4 .Client
126
+ service * cloudflarev0 .API
127
+ serviceV4 * cloudflare .Client
128
128
}
129
129
130
130
func (z zoneService ) ZoneIDByName (zoneName string ) (string , error ) {
131
131
// Use v4 API to find zone by name
132
132
params := zones.ZoneListParams {
133
- Name : cloudflarev4 .F (zoneName ),
133
+ Name : cloudflare .F (zoneName ),
134
134
}
135
135
136
136
iter := z .serviceV4 .Zones .ListAutoPaging (context .Background (), params )
@@ -147,20 +147,20 @@ func (z zoneService) ZoneIDByName(zoneName string) (string, error) {
147
147
return "" , fmt .Errorf ("zone %q not found in CloudFlare account - verify the zone exists and API credentials have access to it" , zoneName )
148
148
}
149
149
150
- func (z zoneService ) CreateDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .CreateDNSRecordParams ) (cloudflare .DNSRecord , error ) {
150
+ func (z zoneService ) CreateDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .CreateDNSRecordParams ) (cloudflarev0 .DNSRecord , error ) {
151
151
return z .service .CreateDNSRecord (ctx , rc , rp )
152
152
}
153
153
154
- func (z zoneService ) ListDNSRecords (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .ListDNSRecordsParams ) ([]cloudflare .DNSRecord , * cloudflare .ResultInfo , error ) {
154
+ func (z zoneService ) ListDNSRecords (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .ListDNSRecordsParams ) ([]cloudflarev0 .DNSRecord , * cloudflarev0 .ResultInfo , error ) {
155
155
return z .service .ListDNSRecords (ctx , rc , rp )
156
156
}
157
157
158
- func (z zoneService ) UpdateDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , rp cloudflare .UpdateDNSRecordParams ) error {
158
+ func (z zoneService ) UpdateDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , rp cloudflarev0 .UpdateDNSRecordParams ) error {
159
159
_ , err := z .service .UpdateDNSRecord (ctx , rc , rp )
160
160
return err
161
161
}
162
162
163
- func (z zoneService ) DeleteDNSRecord (ctx context.Context , rc * cloudflare .ResourceContainer , recordID string ) error {
163
+ func (z zoneService ) DeleteDNSRecord (ctx context.Context , rc * cloudflarev0 .ResourceContainer , recordID string ) error {
164
164
return z .service .DeleteDNSRecord (ctx , rc , recordID )
165
165
}
166
166
@@ -169,18 +169,18 @@ func (z zoneService) ListZones(ctx context.Context, params zones.ZoneListParams)
169
169
}
170
170
171
171
func (z zoneService ) GetZone (ctx context.Context , zoneID string ) (* zones.Zone , error ) {
172
- return z .serviceV4 .Zones .Get (ctx , zones.ZoneGetParams {ZoneID : cloudflarev4 .F (zoneID )})
172
+ return z .serviceV4 .Zones .Get (ctx , zones.ZoneGetParams {ZoneID : cloudflare .F (zoneID )})
173
173
}
174
174
175
- func (z zoneService ) CustomHostnames (ctx context.Context , zoneID string , page int , filter cloudflare .CustomHostname ) ([]cloudflare .CustomHostname , cloudflare .ResultInfo , error ) {
175
+ func (z zoneService ) CustomHostnames (ctx context.Context , zoneID string , page int , filter cloudflarev0 .CustomHostname ) ([]cloudflarev0 .CustomHostname , cloudflarev0 .ResultInfo , error ) {
176
176
return z .service .CustomHostnames (ctx , zoneID , page , filter )
177
177
}
178
178
179
179
func (z zoneService ) DeleteCustomHostname (ctx context.Context , zoneID string , customHostnameID string ) error {
180
180
return z .service .DeleteCustomHostname (ctx , zoneID , customHostnameID )
181
181
}
182
182
183
- func (z zoneService ) CreateCustomHostname (ctx context.Context , zoneID string , ch cloudflare .CustomHostname ) (* cloudflare .CustomHostnameResponse , error ) {
183
+ func (z zoneService ) CreateCustomHostname (ctx context.Context , zoneID string , ch cloudflarev0 .CustomHostname ) (* cloudflarev0 .CustomHostnameResponse , error ) {
184
184
return z .service .CreateCustomHostname (ctx , zoneID , ch )
185
185
}
186
186
@@ -250,35 +250,35 @@ type CloudFlareProvider struct {
250
250
// cloudFlareChange differentiates between ChangeActions
251
251
type cloudFlareChange struct {
252
252
Action changeAction
253
- ResourceRecord cloudflare .DNSRecord
253
+ ResourceRecord cloudflarev0 .DNSRecord
254
254
RegionalHostname regionalHostname
255
- CustomHostnames map [string ]cloudflare .CustomHostname
255
+ CustomHostnames map [string ]cloudflarev0 .CustomHostname
256
256
CustomHostnamesPrev []string
257
257
}
258
258
259
259
// RecordParamsTypes is a typeset of the possible Record Params that can be passed to cloudflare-go library
260
260
type RecordParamsTypes interface {
261
- cloudflare .UpdateDNSRecordParams | cloudflare .CreateDNSRecordParams
261
+ cloudflarev0 .UpdateDNSRecordParams | cloudflarev0 .CreateDNSRecordParams
262
262
}
263
263
264
264
// updateDNSRecordParam is a function that returns the appropriate Record Param based on the cloudFlareChange passed in
265
- func updateDNSRecordParam (cfc cloudFlareChange ) cloudflare .UpdateDNSRecordParams {
266
- params := cloudflare .UpdateDNSRecordParams {
265
+ func updateDNSRecordParam (cfc cloudFlareChange ) cloudflarev0 .UpdateDNSRecordParams {
266
+ params := cloudflarev0 .UpdateDNSRecordParams {
267
267
Name : cfc .ResourceRecord .Name ,
268
268
TTL : cfc .ResourceRecord .TTL ,
269
269
Proxied : cfc .ResourceRecord .Proxied ,
270
270
Type : cfc .ResourceRecord .Type ,
271
271
Content : cfc .ResourceRecord .Content ,
272
272
Priority : cfc .ResourceRecord .Priority ,
273
- Comment : cloudflare .StringPtr (cfc .ResourceRecord .Comment ),
273
+ Comment : cloudflarev0 .StringPtr (cfc .ResourceRecord .Comment ),
274
274
}
275
275
276
276
return params
277
277
}
278
278
279
279
// getCreateDNSRecordParam is a function that returns the appropriate Record Param based on the cloudFlareChange passed in
280
- func getCreateDNSRecordParam (cfc cloudFlareChange ) cloudflare .CreateDNSRecordParams {
281
- params := cloudflare .CreateDNSRecordParams {
280
+ func getCreateDNSRecordParam (cfc cloudFlareChange ) cloudflarev0 .CreateDNSRecordParams {
281
+ params := cloudflarev0 .CreateDNSRecordParams {
282
282
Name : cfc .ResourceRecord .Name ,
283
283
TTL : cfc .ResourceRecord .TTL ,
284
284
Proxied : cfc .ResourceRecord .Proxied ,
@@ -292,7 +292,7 @@ func getCreateDNSRecordParam(cfc cloudFlareChange) cloudflare.CreateDNSRecordPar
292
292
}
293
293
294
294
func convertCloudflareError (err error ) error {
295
- var apiErr * cloudflare .Error
295
+ var apiErr * cloudflarev0 .Error
296
296
if errors .As (err , & apiErr ) {
297
297
if apiErr .ClientRateLimited () || apiErr .StatusCode >= http .StatusInternalServerError {
298
298
// Handle rate limit error as a soft error
@@ -320,8 +320,8 @@ func NewCloudFlareProvider(
320
320
) (* CloudFlareProvider , error ) {
321
321
// initialize via chosen auth method and returns new API object
322
322
var (
323
- config * cloudflare .API
324
- configV4 * cloudflarev4 .Client
323
+ config * cloudflarev0 .API
324
+ configV4 * cloudflare .Client
325
325
err error
326
326
)
327
327
if os .Getenv ("CF_API_TOKEN" ) != "" {
@@ -333,13 +333,13 @@ func NewCloudFlareProvider(
333
333
}
334
334
token = strings .TrimSpace (string (tokenBytes ))
335
335
}
336
- config , err = cloudflare .NewWithAPIToken (token )
337
- configV4 = cloudflarev4 .NewClient (
336
+ config , err = cloudflarev0 .NewWithAPIToken (token )
337
+ configV4 = cloudflare .NewClient (
338
338
option .WithAPIToken (token ),
339
339
)
340
340
} else {
341
- config , err = cloudflare .New (os .Getenv ("CF_API_KEY" ), os .Getenv ("CF_API_EMAIL" ))
342
- configV4 = cloudflarev4 .NewClient (
341
+ config , err = cloudflarev0 .New (os .Getenv ("CF_API_KEY" ), os .Getenv ("CF_API_EMAIL" ))
342
+ configV4 = cloudflare .NewClient (
343
343
option .WithAPIKey (os .Getenv ("CF_API_KEY" )),
344
344
option .WithAPIEmail (os .Getenv ("CF_API_EMAIL" )),
345
345
)
@@ -617,7 +617,7 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
617
617
var failedZones []string
618
618
for zoneID , zoneChanges := range changesByZone {
619
619
var failedChange bool
620
- resourceContainer := cloudflare .ZoneIdentifier (zoneID )
620
+ resourceContainer := cloudflarev0 .ZoneIdentifier (zoneID )
621
621
622
622
for _ , change := range zoneChanges {
623
623
logFields := log.Fields {
@@ -769,25 +769,25 @@ func (p *CloudFlareProvider) changesByZone(zones []zones.Zone, changeSet []*clou
769
769
return changes
770
770
}
771
771
772
- func (p * CloudFlareProvider ) getRecordID (records DNSRecordsMap , record cloudflare .DNSRecord ) string {
772
+ func (p * CloudFlareProvider ) getRecordID (records DNSRecordsMap , record cloudflarev0 .DNSRecord ) string {
773
773
if zoneRecord , ok := records [DNSRecordIndex {Name : record .Name , Type : record .Type , Content : record .Content }]; ok {
774
774
return zoneRecord .ID
775
775
}
776
776
return ""
777
777
}
778
778
779
- func getCustomHostname (chs CustomHostnamesMap , chName string ) (cloudflare .CustomHostname , error ) {
779
+ func getCustomHostname (chs CustomHostnamesMap , chName string ) (cloudflarev0 .CustomHostname , error ) {
780
780
if chName == "" {
781
- return cloudflare .CustomHostname {}, fmt .Errorf ("failed to get custom hostname: %q is empty" , chName )
781
+ return cloudflarev0 .CustomHostname {}, fmt .Errorf ("failed to get custom hostname: %q is empty" , chName )
782
782
}
783
783
if ch , ok := chs [CustomHostnameIndex {Hostname : chName }]; ok {
784
784
return ch , nil
785
785
}
786
- return cloudflare .CustomHostname {}, fmt .Errorf ("failed to get custom hostname: %q not found" , chName )
786
+ return cloudflarev0 .CustomHostname {}, fmt .Errorf ("failed to get custom hostname: %q not found" , chName )
787
787
}
788
788
789
- func (p * CloudFlareProvider ) newCustomHostname (customHostname string , origin string ) cloudflare .CustomHostname {
790
- return cloudflare .CustomHostname {
789
+ func (p * CloudFlareProvider ) newCustomHostname (customHostname string , origin string ) cloudflarev0 .CustomHostname {
790
+ return cloudflarev0 .CustomHostname {
791
791
Hostname : customHostname ,
792
792
CustomOriginServer : origin ,
793
793
SSL : getCustomHostnamesSSLOptions (p .CustomHostnamesConfig ),
@@ -803,7 +803,7 @@ func (p *CloudFlareProvider) newCloudFlareChange(action changeAction, ep *endpoi
803
803
}
804
804
805
805
prevCustomHostnames := []string {}
806
- newCustomHostnames := map [string ]cloudflare .CustomHostname {}
806
+ newCustomHostnames := map [string ]cloudflarev0 .CustomHostname {}
807
807
if p .CustomHostnamesConfig .Enabled {
808
808
if current != nil {
809
809
prevCustomHostnames = getEndpointCustomHostnames (current )
@@ -837,7 +837,7 @@ func (p *CloudFlareProvider) newCloudFlareChange(action changeAction, ep *endpoi
837
837
838
838
return & cloudFlareChange {
839
839
Action : action ,
840
- ResourceRecord : cloudflare .DNSRecord {
840
+ ResourceRecord : cloudflarev0 .DNSRecord {
841
841
Name : ep .DNSName ,
842
842
TTL : ttl ,
843
843
// We have to use pointers to bools now, as the upstream cloudflare-go library requires them
@@ -854,18 +854,18 @@ func (p *CloudFlareProvider) newCloudFlareChange(action changeAction, ep *endpoi
854
854
}, nil
855
855
}
856
856
857
- func newDNSRecordIndex (r cloudflare .DNSRecord ) DNSRecordIndex {
857
+ func newDNSRecordIndex (r cloudflarev0 .DNSRecord ) DNSRecordIndex {
858
858
return DNSRecordIndex {Name : r .Name , Type : r .Type , Content : r .Content }
859
859
}
860
860
861
861
// listDNSRecordsWithAutoPagination performs automatic pagination of results on requests to cloudflare.ListDNSRecords with custom per_page values
862
862
func (p * CloudFlareProvider ) listDNSRecordsWithAutoPagination (ctx context.Context , zoneID string ) (DNSRecordsMap , error ) {
863
863
// for faster getRecordID lookup
864
864
records := make (DNSRecordsMap )
865
- resultInfo := cloudflare .ResultInfo {PerPage : p .DNSRecordsConfig .PerPage , Page : 1 }
866
- params := cloudflare .ListDNSRecordsParams {ResultInfo : resultInfo }
865
+ resultInfo := cloudflarev0 .ResultInfo {PerPage : p .DNSRecordsConfig .PerPage , Page : 1 }
866
+ params := cloudflarev0 .ListDNSRecordsParams {ResultInfo : resultInfo }
867
867
for {
868
- pageRecords , resultInfo , err := p .Client .ListDNSRecords (ctx , cloudflare .ZoneIdentifier (zoneID ), params )
868
+ pageRecords , resultInfo , err := p .Client .ListDNSRecords (ctx , cloudflarev0 .ZoneIdentifier (zoneID ), params )
869
869
if err != nil {
870
870
return nil , convertCloudflareError (err )
871
871
}
@@ -881,7 +881,7 @@ func (p *CloudFlareProvider) listDNSRecordsWithAutoPagination(ctx context.Contex
881
881
return records , nil
882
882
}
883
883
884
- func newCustomHostnameIndex (ch cloudflare .CustomHostname ) CustomHostnameIndex {
884
+ func newCustomHostnameIndex (ch cloudflarev0 .CustomHostname ) CustomHostnameIndex {
885
885
return CustomHostnameIndex {Hostname : ch .Hostname }
886
886
}
887
887
@@ -891,9 +891,9 @@ func (p *CloudFlareProvider) listCustomHostnamesWithPagination(ctx context.Conte
891
891
return nil , nil
892
892
}
893
893
chs := make (CustomHostnamesMap )
894
- resultInfo := cloudflare .ResultInfo {Page : 1 }
894
+ resultInfo := cloudflarev0 .ResultInfo {Page : 1 }
895
895
for {
896
- pageCustomHostnameListResponse , result , err := p .Client .CustomHostnames (ctx , zoneID , resultInfo .Page , cloudflare .CustomHostname {})
896
+ pageCustomHostnameListResponse , result , err := p .Client .CustomHostnames (ctx , zoneID , resultInfo .Page , cloudflarev0 .CustomHostname {})
897
897
if err != nil {
898
898
convertedError := convertCloudflareError (err )
899
899
if ! errors .Is (convertedError , provider .SoftError ) {
@@ -912,12 +912,12 @@ func (p *CloudFlareProvider) listCustomHostnamesWithPagination(ctx context.Conte
912
912
return chs , nil
913
913
}
914
914
915
- func getCustomHostnamesSSLOptions (customHostnamesConfig CustomHostnamesConfig ) * cloudflare .CustomHostnameSSL {
916
- ssl := & cloudflare .CustomHostnameSSL {
915
+ func getCustomHostnamesSSLOptions (customHostnamesConfig CustomHostnamesConfig ) * cloudflarev0 .CustomHostnameSSL {
916
+ ssl := & cloudflarev0 .CustomHostnameSSL {
917
917
Type : "dv" ,
918
918
Method : "http" ,
919
919
BundleMethod : "ubiquitous" ,
920
- Settings : cloudflare .CustomHostnameSSLSettings {
920
+ Settings : cloudflarev0 .CustomHostnameSSLSettings {
921
921
MinTLSVersion : customHostnamesConfig .MinTLSVersion ,
922
922
},
923
923
}
@@ -964,7 +964,7 @@ func (p *CloudFlareProvider) groupByNameAndTypeWithCustomHostnames(records DNSRe
964
964
var endpoints []* endpoint.Endpoint
965
965
966
966
// group supported records by name and type
967
- groups := map [string ][]cloudflare .DNSRecord {}
967
+ groups := map [string ][]cloudflarev0 .DNSRecord {}
968
968
969
969
for _ , r := range records {
970
970
if ! p .SupportedAdditionalRecordTypes (r .Type ) {
@@ -973,7 +973,7 @@ func (p *CloudFlareProvider) groupByNameAndTypeWithCustomHostnames(records DNSRe
973
973
974
974
groupBy := r .Name + r .Type
975
975
if _ , ok := groups [groupBy ]; ! ok {
976
- groups [groupBy ] = []cloudflare .DNSRecord {}
976
+ groups [groupBy ] = []cloudflarev0 .DNSRecord {}
977
977
}
978
978
979
979
groups [groupBy ] = append (groups [groupBy ], r )
0 commit comments