Skip to content
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

Bump Cloudflare-Go #2298

Merged
merged 4 commits into from
Dec 17, 2021

Conversation

dmizelle
Copy link
Contributor

Description
In order for us to use some new features provided by cloudflare-go for
the cloudflare provider (mainly around Cloudflare Access, etc.) we need
to bump the version of cloudflare-go used.

The only real change that needed to be done was that the Proxied field
on cloudflare.DNSRecord structs changed from bool -> *bool.
Upstream did this because in certain cases, a user could not flip from
proxied -> DNS only (the library omitted sending proxied = false to
the API)

Other decent change was that most methods exported by the library now
require context.Context to be passed in. Was rather trivial to get up.

cloudflare/cloudflare-go#595

Signed-off-by: Devon Mizelle devon.mizelle@onepeloton.com

Checklist

  • Unit tests updated
  • [N/A] End user documentation updated

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 15, 2021
TTL: 120,
Content: "1.2.3.4",
Proxied: test.RecordsAreProxied,
t.Run(test.Name, func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to do this as it was hard to figure out what test case was failing.

// see: https://github.com/cloudflare/cloudflare-go/pull/595

// ProxyEnabled is a pointer to a bool true showing the record should be proxied through cloudflare
var ProxyEnabled *bool = &[]bool{true}[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh im not really happy about this message thing of creating a slice of bool, setting first element to true, and getting that element.

i wish there was a better way to do this, and am 500% all ears.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋🏻 WDYT about creating a helper function which return a bool pointer? I think this used in a lot of packages (IIRC aws-sdk-go definitely has this), it's a bit more readable IMHO.

func Bool() *bool {
    b := true
    return &b
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be also proxyEnabled.

@dmizelle
Copy link
Contributor Author

Hm, this breaks when doing local testing unfortunately:

INFO[0000] Created Kubernetes client https://0.0.0.0:42077
FATA[0000] unexpected pagination options passed to functions that handle pagination automatically

will look further

@dmizelle
Copy link
Contributor Author

dmizelle commented Sep 16, 2021

Looks like they made ListZonesContext not take pagination anymore, and the function itself does the pagination for you:

https://github.com/cloudflare/cloudflare-go/blob/v0.22.0/zone.go#L441-L443

Introduced in cloudflare/cloudflare-go#674

Should be ready for review.

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 29, 2021
Devon Mizelle added 3 commits September 30, 2021 21:30
In order for us to use some new features provided by cloudflare-go for
the cloudflare provider (mainly around Cloudflare Access, etc.) we need
to bump the version of cloudflare-go used.

The only real change that needed to be done was that the `Proxied` field
on `cloudflare.DNSRecord` structs changed from `bool` -> `*bool`.
Upstream did this because in certain cases, a user could not flip from
proxied -> DNS only (the library omitted sending `proxied = false` to
the API)

Other decent change was that most methods exported by the library now
require `context.Context` to be passed in. Was rather trivial to get up.

cloudflare/cloudflare-go#595

Signed-off-by: Devon Mizelle <devon.mizelle@onepeloton.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 1, 2021
Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits, but lgtm.

// see: https://github.com/cloudflare/cloudflare-go/pull/595

// ProxyEnabled is a pointer to a bool true showing the record should be proxied through cloudflare
var ProxyEnabled *bool = &[]bool{true}[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋🏻 WDYT about creating a helper function which return a bool pointer? I think this used in a lot of packages (IIRC aws-sdk-go definitely has this), it's a bit more readable IMHO.

func Bool() *bool {
    b := true
    return &b
}

// see: https://github.com/cloudflare/cloudflare-go/pull/595

// ProxyEnabled is a pointer to a bool true showing the record should be proxied through cloudflare
var ProxyEnabled *bool = &[]bool{true}[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be also proxyEnabled.

var ProxyEnabled *bool = &[]bool{true}[0]

// ProxyDisabled is a pointer to a bool false showing the record should not be proxied through cloudflare
var ProxyDisabled *bool = &[]bool{false}[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use !proxyEnabled instead or do you think it's more readable having proxyDisabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its more readable/explicit this way

@@ -177,24 +186,20 @@ func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, erro
}

log.Debugln("no zoneIDFilter configured, looking at all zones")
for {
zonesResponse, err := p.Client.ListZonesContext(ctx, cloudflare.WithPagination(p.PaginationOptions))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no pagination needed anymore? We had to implement it if you'd have more than x zones in Cloudflare otherwise it wouldn't change all DNS zones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! See #2298 (comment)

Makes it easier for us :)

@njuettner njuettner self-assigned this Oct 14, 2021
go.mod Outdated
@@ -17,7 +17,7 @@ require (
github.com/aliyun/alibaba-cloud-sdk-go v1.61.357
github.com/aws/aws-sdk-go v1.40.38
github.com/bodgit/tsig v0.0.2
github.com/cloudflare/cloudflare-go v0.13.2
github.com/cloudflare/cloudflare-go v0.22.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can we bump this to 0.25.0? I saw dependabot wanted to update it.

* Bump cloudflare-go to 0.25.0
* Use a function for pointer booleans rather than hardcoding it.
@dmizelle
Copy link
Contributor Author

hey @njuettner -- thanks for the review. updated with a new commit.

Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dmizelle, njuettner

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2021
@k8s-ci-robot k8s-ci-robot merged commit 58bc1df into kubernetes-sigs:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants