-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(cloudflare): Suppport DNS record comments #5411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudflare): Suppport DNS record comments #5411
Conversation
Hi @7onn. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest is reviewed here #5359
provider/cloudflare/cloudflare.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance to move this logic under struct? To reduce complexity of current method?
Example
func (cfg DNSRecordsConfig) trimAndValidateComment( isPaidZone bool, comment, dnsName string) string {
if len(comment) > freeZoneMaxCommentLength {
if !isPaidZone {
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-1]
} 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-1]
}
}
return comment
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated! :) also improved the new test cases by iterating comment cases and covering all possibilities.
/label tide/merge-method-squash |
302ca0a
to
3b44372
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
I suggest to open a PR with documentation/examples update. If no plans to add docs as part of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
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] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional, as there are so many comments already. depends on readability/personal preference, but sometimes it's easier to read when there is a reduced nesting
example
if len(comment) <= freeZoneMaxCommentLength { return # early return }
if / else {}
which will be something like with early return
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk, mloiseleur The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
there seems to be a bug preventing the cmd line flag @7onn please let me know if you'll pick it up from there, or prefer the issue to be created or me to fix it |
it was fixed already! just waiting for a patch!!! https://github.com/kubernetes-sigs/external-dns/pull/5582/files |
Description
This will add a flags to be used on the Cloudflare provider for making
comment
available for DNS records. That's helpful when you already have a lot of records and you'd like to track what external-dns is provisioning there and why.Comment can be set as follows
--cloudflare-record-comment="Ingresses for my domain"
Fixes #3934
This is a subset of #5359
Tags were posing issues to work without causing a config drift and endless syncs; Will address these separately on a subsequent pull request.
Checklist