@@ -229,7 +229,7 @@ func NewCloudFlareProvider(domainFilter endpoint.DomainFilter, zoneIDFilter prov
229
229
config , err = cloudflare .New (os .Getenv ("CF_API_KEY" ), os .Getenv ("CF_API_EMAIL" ))
230
230
}
231
231
if err != nil {
232
- return nil , fmt .Errorf ("failed to initialize cloudflare provider: %v " , err )
232
+ return nil , fmt .Errorf ("failed to initialize cloudflare provider: %w " , err )
233
233
}
234
234
provider := & CloudFlareProvider {
235
235
// Client: config,
@@ -254,10 +254,10 @@ func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, erro
254
254
if len (p .zoneIDFilter .ZoneIDs ) > 0 && p .zoneIDFilter .ZoneIDs [0 ] != "" {
255
255
log .Debugln ("zoneIDFilter configured. only looking up zone IDs defined" )
256
256
for _ , zoneID := range p .zoneIDFilter .ZoneIDs {
257
- log .Debugf ("looking up zone %s " , zoneID )
257
+ log .Debugf ("looking up zone %q " , zoneID )
258
258
detailResponse , err := p .Client .ZoneDetails (ctx , zoneID )
259
259
if err != nil {
260
- log .Errorf ("zone %s lookup failed, %v" , zoneID , err )
260
+ log .Errorf ("zone %q lookup failed, %v" , zoneID , err )
261
261
return result , err
262
262
}
263
263
log .WithFields (log.Fields {
@@ -285,7 +285,7 @@ func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, erro
285
285
286
286
for _ , zone := range zonesResponse .Result {
287
287
if ! p .domainFilter .Match (zone .Name ) {
288
- log .Debugf ("zone %s not in domain filter" , zone .Name )
288
+ log .Debugf ("zone %q not in domain filter" , zone .Name )
289
289
continue
290
290
}
291
291
result = append (result , zone )
@@ -395,7 +395,7 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
395
395
resourceContainer := cloudflare .ZoneIdentifier (zoneID )
396
396
records , err := p .listDNSRecordsWithAutoPagination (ctx , zoneID )
397
397
if err != nil {
398
- return fmt .Errorf ("could not fetch records from zone, %v " , err )
398
+ return fmt .Errorf ("could not fetch records from zone, %w " , err )
399
399
}
400
400
chs , chErr := p .listCustomHostnamesWithPagination (ctx , zoneID )
401
401
if chErr != nil {
@@ -408,21 +408,21 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
408
408
if prevCh , err := getCustomHostname (chs , prevChName ); err == nil {
409
409
prevChID := prevCh .ID
410
410
if prevChID != "" && prevChName != newChName {
411
- log .WithFields (logFields ).Infof ("Removing previous custom hostname %v/%v " , prevChID , prevChName )
411
+ log .WithFields (logFields ).Infof ("Removing previous custom hostname %q/%q " , prevChID , prevChName )
412
412
chErr := p .Client .DeleteCustomHostname (ctx , zoneID , prevChID )
413
413
if chErr != nil {
414
414
failedChange = true
415
- log .WithFields (logFields ).Errorf ("failed to remove previous custom hostname %v/%v : %v" , prevChID , prevChName , chErr )
415
+ log .WithFields (logFields ).Errorf ("failed to remove previous custom hostname %q/%q : %v" , prevChID , prevChName , chErr )
416
416
}
417
417
}
418
418
}
419
419
if newChName != "" {
420
420
if prevChName != newChName {
421
- log .WithFields (logFields ).Infof ("Adding custom hostname %v " , newChName )
421
+ log .WithFields (logFields ).Infof ("Adding custom hostname %q " , newChName )
422
422
_ , chErr := p .Client .CreateCustomHostname (ctx , zoneID , change .CustomHostname )
423
423
if chErr != nil {
424
424
failedChange = true
425
- log .WithFields (logFields ).Errorf ("failed to add custom hostname %v : %v" , newChName , chErr )
425
+ log .WithFields (logFields ).Errorf ("failed to add custom hostname %q : %v" , newChName , chErr )
426
426
}
427
427
}
428
428
}
@@ -458,16 +458,16 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
458
458
log .WithFields (logFields ).Errorf ("failed to delete record: %v" , err )
459
459
}
460
460
if recordTypeCustomHostnameSupported [change .ResourceRecord .Type ] && change .CustomHostname .Hostname != "" {
461
- log .WithFields (logFields ).Infof ("Deleting custom hostname %v " , change .CustomHostname .Hostname )
461
+ log .WithFields (logFields ).Infof ("Deleting custom hostname %q " , change .CustomHostname .Hostname )
462
462
if ch , err := getCustomHostname (chs , change .CustomHostname .Hostname ); err == nil {
463
463
chID := ch .ID
464
464
chErr := p .Client .DeleteCustomHostname (ctx , zoneID , chID )
465
465
if chErr != nil {
466
466
failedChange = true
467
- log .WithFields (logFields ).Errorf ("failed to delete custom hostname %v/%v : %v" , chID , change .CustomHostname .Hostname , chErr )
467
+ log .WithFields (logFields ).Errorf ("failed to delete custom hostname %q/%q : %v" , chID , change .CustomHostname .Hostname , chErr )
468
468
}
469
469
} else {
470
- log .WithFields (logFields ).Warnf ("failed to delete custom hostname %v : %v" , change .CustomHostname .Hostname , err )
470
+ log .WithFields (logFields ).Warnf ("failed to delete custom hostname %q : %v" , change .CustomHostname .Hostname , err )
471
471
}
472
472
}
473
473
} else if change .Action == cloudFlareCreate {
@@ -478,19 +478,19 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
478
478
log .WithFields (logFields ).Errorf ("failed to create record: %v" , err )
479
479
}
480
480
if recordTypeCustomHostnameSupported [change .ResourceRecord .Type ] && change .CustomHostname .Hostname != "" {
481
- log .WithFields (logFields ).Infof ("Creating custom hostname %v " , change .CustomHostname .Hostname )
481
+ log .WithFields (logFields ).Infof ("Creating custom hostname %q " , change .CustomHostname .Hostname )
482
482
if ch , err := getCustomHostname (chs , change .CustomHostname .Hostname ); err == nil {
483
483
if change .CustomHostname .CustomOriginServer == ch .CustomOriginServer {
484
- log .WithFields (logFields ).Warnf ("custom hostname %v already exists with the same origin %v , continue" , change .CustomHostname .Hostname , ch .CustomOriginServer )
484
+ log .WithFields (logFields ).Warnf ("custom hostname %q already exists with the same origin %q , continue" , change .CustomHostname .Hostname , ch .CustomOriginServer )
485
485
} else {
486
486
failedChange = true
487
- log .WithFields (logFields ).Errorf ("failed to create custom hostname, %v already exists with origin %v " , change .CustomHostname .Hostname , ch .CustomOriginServer )
487
+ log .WithFields (logFields ).Errorf ("failed to create custom hostname, %q already exists with origin %q " , change .CustomHostname .Hostname , ch .CustomOriginServer )
488
488
}
489
489
} else {
490
490
_ , chErr := p .Client .CreateCustomHostname (ctx , zoneID , change .CustomHostname )
491
491
if chErr != nil {
492
492
failedChange = true
493
- log .WithFields (logFields ).Errorf ("failed to create custom hostname %v : %v" , change .CustomHostname .Hostname , chErr )
493
+ log .WithFields (logFields ).Errorf ("failed to create custom hostname %q : %v" , change .CustomHostname .Hostname , chErr )
494
494
}
495
495
}
496
496
}
@@ -502,7 +502,7 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
502
502
}
503
503
504
504
if len (failedZones ) > 0 {
505
- return fmt .Errorf ("failed to submit all changes for the following zones: %v " , failedZones )
505
+ return fmt .Errorf ("failed to submit all changes for the following zones: %q " , failedZones )
506
506
}
507
507
508
508
return nil
@@ -536,7 +536,7 @@ func (p *CloudFlareProvider) changesByZone(zones []cloudflare.Zone, changeSet []
536
536
for _ , c := range changeSet {
537
537
zoneID , _ := zoneNameIDMapper .FindZone (c .ResourceRecord .Name )
538
538
if zoneID == "" {
539
- log .Debugf ("Skipping record %s because no hosted zone matching record DNS Name was detected" , c .ResourceRecord .Name )
539
+ log .Debugf ("Skipping record %q because no hosted zone matching record DNS Name was detected" , c .ResourceRecord .Name )
540
540
continue
541
541
}
542
542
changes [zoneID ] = append (changes [zoneID ], c )
@@ -655,7 +655,7 @@ func (p *CloudFlareProvider) listCustomHostnamesWithPagination(ctx context.Conte
655
655
return nil , provider .NewSoftError (err )
656
656
}
657
657
}
658
- log .Errorf ("zone %s failed to fetch custom hostnames. Please check if \" Cloudflare for SaaS\" is enabled and API key permissions, %v" , zoneID , err )
658
+ log .Errorf ("zone %q failed to fetch custom hostnames. Please check if \" Cloudflare for SaaS\" is enabled and API key permissions, %v" , zoneID , err )
659
659
return nil , err
660
660
}
661
661
@@ -687,7 +687,7 @@ func shouldBeProxied(endpoint *endpoint.Endpoint, proxiedByDefault bool) bool {
687
687
if v .Name == source .CloudflareProxiedKey {
688
688
b , err := strconv .ParseBool (v .Value )
689
689
if err != nil {
690
- log .Errorf ("Failed to parse annotation [%s ]: %v" , source .CloudflareProxiedKey , err )
690
+ log .Errorf ("Failed to parse annotation [%q ]: %v" , source .CloudflareProxiedKey , err )
691
691
} else {
692
692
proxied = b
693
693
}
0 commit comments