-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow ZoneIDFilter for Cloudflare #1494
Allow ZoneIDFilter for Cloudflare #1494
Conversation
Welcome @james-callahan! |
/assign @hjacobs |
Here's an image with the changes. i built it as I needed it for a project and it works as intended: https://hub.docker.com/layers/drgrove/external-dns/0.7.1_dev1/images/sha256-27b1618cb574ec6a3a79cec4ba4e909c2b1d0c75f399851f1092bdaa54abc334?context=repo |
CI failure seems unrelated:
|
Thanks, can you please rebase from master again, should be fixed now 👍. |
be5cd89
to
adb8143
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.
Added some comments, PTAL.
provider/cloudflare.go
Outdated
@@ -150,6 +155,26 @@ func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, erro | |||
result := []cloudflare.Zone{} | |||
p.PaginationOptions.Page = 1 | |||
|
|||
// if there is a zoneIDfilter configured |
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.
I don't think this is needed, the code already explains it so I would drop the comments
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.
(note: I didn't write this: the author of #1307 did):
The following line that notes that empty strings are used by tests is informative.
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.
Ah I see my bad, I would still like to drop those lines. Maybe only keep the second ... blank string for unit tests ...
provider/cloudflare.go
Outdated
@@ -150,6 +155,26 @@ func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, erro | |||
result := []cloudflare.Zone{} | |||
p.PaginationOptions.Page = 1 | |||
|
|||
// if there is a zoneIDfilter configured | |||
// && if the filter isnt just a blank string (used in tests) | |||
if len(p.zoneIDFilter.zoneIDs) > 0 && p.zoneIDFilter.zoneIDs[0] != "" { |
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.
Maybe you could add a new method ZoneDetailsByDomainFilter which includes your code.
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.
or ListZonesByIDFilter
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.
I tried to split this off (and create functions that each returned iterators) but my minimal knowledge of Go wasn't enough to get things working.
Splitting off just the contents of this branch didn't seem to improve readability.
provider/cloudflare.go
Outdated
continue | ||
} | ||
|
||
if !p.zoneIDFilter.Match(zone.ID) { |
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.
Just to understand it a bit better, this is dropped because it's not working?
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.
Dropped because if there was any zoneIDFilter then the above branch would be taken and this code is unreachable.
Cheering for this to be merged. Right now I need to issue access token that has access to read all zones |
…lter Allow ZoneIDFilter for Cloudflare
…lter Allow ZoneIDFilter for Cloudflare
adb8143
to
d0a05c6
Compare
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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/test-infra repository. I understand the commands that are listed here. |
d0a05c6
to
87dce22
Compare
87dce22
to
ae5e894
Compare
/assign @sheerun |
@james-callahan Please sign CLA |
Or is it @dmizelle that haven't signed? |
cla check passed: it is dmizelle's code. |
I need to consult kubernetes team what to do in cases like this... |
Two things smell bad here:
|
This commit _should_ help kubernetes-sigs#1127. While users in the past were able to define ZoneIDFilter for this provider, it did not actually do anything under the hood. In this case, we're changing Zones() to iterate over the provided zoneIDs and return only those zones. I would have also done this for domainFilter, but unfortunately the CloudFlare API requires that in order to list zones (and find them by name) that you have "all" permissions, which seems silly. After talking to their support, this is probably the best way to do this. Signed-off-by: James Callahan <jamescallahan@bitgo.com>
ae5e894
to
60d4ef2
Compare
Why not?
Fixed. |
I thought that ZoneList supports multiple domains, but it's probably not the case: https://community.cloudflare.com/t/bug-zone-detail-by-name-requires-zone-list-permission/128042/15 |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: james-callahan, sheerun 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 |
/lgtm |
This PR is a rebased and cleaned up #1307