mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
fix(cloudflare): set comments properly (#5582)
* fix(cloudflare): Set comments properly * Use cloudflare.StringPtr to enable comment removal
This commit is contained in:
parent
73b8fb0da7
commit
3e7c5cd2c1
@ -115,7 +115,6 @@ type Config struct {
|
||||
CloudflareCustomHostnamesCertificateAuthority string
|
||||
CloudflareRegionalServices bool
|
||||
CloudflareRegionKey string
|
||||
CloudflareRecordComment string
|
||||
CoreDNSPrefix string
|
||||
AkamaiServiceConsumerDomain string
|
||||
AkamaiClientToken string
|
||||
@ -535,7 +534,7 @@ func App(cfg *Config) *kingpin.Application {
|
||||
app.Flag("cloudflare-dns-records-per-page", "When using the Cloudflare provider, specify how many DNS records listed per page, max possible 5,000 (default: 100)").Default(strconv.Itoa(defaultConfig.CloudflareDNSRecordsPerPage)).IntVar(&cfg.CloudflareDNSRecordsPerPage)
|
||||
app.Flag("cloudflare-regional-services", "When using the Cloudflare provider, specify if Regional Services feature will be used (default: disabled)").Default(strconv.FormatBool(defaultConfig.CloudflareRegionalServices)).BoolVar(&cfg.CloudflareRegionalServices)
|
||||
app.Flag("cloudflare-region-key", "When using the Cloudflare provider, specify the default region for Regional Services. Any value other than an empty string will enable the Regional Services feature (optional)").StringVar(&cfg.CloudflareRegionKey)
|
||||
app.Flag("cloudflare-record-comment", "When using the Cloudflare provider, specify the comment for the DNS records (default: '')").Default("").StringVar(&cfg.CloudflareRecordComment)
|
||||
app.Flag("cloudflare-record-comment", "When using the Cloudflare provider, specify the comment for the DNS records (default: '')").Default("").StringVar(&cfg.CloudflareDNSRecordsComment)
|
||||
|
||||
app.Flag("coredns-prefix", "When using the CoreDNS provider, specify the prefix name").Default(defaultConfig.CoreDNSPrefix).StringVar(&cfg.CoreDNSPrefix)
|
||||
app.Flag("akamai-serviceconsumerdomain", "When using the Akamai provider, specify the base URL (required when --provider=akamai and edgerc-path not specified)").Default(defaultConfig.AkamaiServiceConsumerDomain).StringVar(&cfg.AkamaiServiceConsumerDomain)
|
||||
|
@ -173,15 +173,20 @@ type DNSRecordsConfig struct {
|
||||
}
|
||||
|
||||
func (c *DNSRecordsConfig) trimAndValidateComment(dnsName, comment string, paidZone func(string) bool) string {
|
||||
if len(comment) > freeZoneMaxCommentLength {
|
||||
if !paidZone(dnsName) {
|
||||
log.Warnf("DNS record comment is invalid. Trimming comment of %s. To avoid endless syncs, please set it to less than %d chars.", dnsName, freeZoneMaxCommentLength)
|
||||
return comment[:freeZoneMaxCommentLength]
|
||||
} else if len(comment) > paidZoneMaxCommentLength {
|
||||
log.Warnf("DNS record comment is invalid. Trimming comment of %s. To avoid endless syncs, please set it to less than %d chars.", dnsName, paidZoneMaxCommentLength)
|
||||
return comment[:paidZoneMaxCommentLength]
|
||||
}
|
||||
if len(comment) <= freeZoneMaxCommentLength {
|
||||
return comment
|
||||
}
|
||||
|
||||
maxLength := freeZoneMaxCommentLength
|
||||
if paidZone(dnsName) {
|
||||
maxLength = paidZoneMaxCommentLength
|
||||
}
|
||||
|
||||
if len(comment) > maxLength {
|
||||
log.Warnf("DNS record comment is invalid. Trimming comment of %s. To avoid endless syncs, please set it to less than %d chars.", dnsName, maxLength)
|
||||
return comment[:maxLength]
|
||||
}
|
||||
|
||||
return comment
|
||||
}
|
||||
|
||||
@ -243,6 +248,7 @@ func updateDNSRecordParam(cfc cloudFlareChange) cloudflare.UpdateDNSRecordParams
|
||||
Type: cfc.ResourceRecord.Type,
|
||||
Content: cfc.ResourceRecord.Content,
|
||||
Priority: cfc.ResourceRecord.Priority,
|
||||
Comment: cloudflare.StringPtr(cfc.ResourceRecord.Comment),
|
||||
}
|
||||
|
||||
return params
|
||||
@ -257,6 +263,7 @@ func getCreateDNSRecordParam(cfc cloudFlareChange) cloudflare.CreateDNSRecordPar
|
||||
Type: cfc.ResourceRecord.Type,
|
||||
Content: cfc.ResourceRecord.Content,
|
||||
Priority: cfc.ResourceRecord.Priority,
|
||||
Comment: cfc.ResourceRecord.Comment,
|
||||
}
|
||||
|
||||
return params
|
||||
|
Loading…
Reference in New Issue
Block a user