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

dns: Proxied to become a boolean pointer #595

Merged
merged 4 commits into from
Feb 22, 2021

Conversation

jacobbednarz
Copy link
Member

@jacobbednarz jacobbednarz commented Feb 22, 2021

Fixes an inability to send a false proxied value to the API.

type DNSRecord struct {
	Type    string `json:"type,omitempty"`
	Proxied bool   `json:"proxied,omitempty"`
}

func main() {
	a, _ := json.Marshal(DNSRecord{
		Type:    "MX",
		Proxied: true,
	})
	fmt.Println(string(a))
	// => {"type":"MX","proxied":true}
	
	b, _ := json.Marshal(DNSRecord{
		Type:    "MX",
		Proxied: false,
	})
	fmt.Println(string(b))
	// => {"type":"MX"}
}

After swapping to *bool

type DNSRecord struct {
	Type    string `json:"type,omitempty"`
	Proxied *bool  `json:"proxied,omitempty"`
}

func main() {
	a, _ := json.Marshal(DNSRecord{
		Type:    "MX",
		Proxied: &[]bool{true}[0],
	})
	fmt.Println(string(a))
	// => {"type":"MX","proxied":true}

	b, _ := json.Marshal(DNSRecord{
		Type:    "MX",
		Proxied: &[]bool{false}[0],
	})
	fmt.Println(string(b))
	// => {"type":"MX","proxied":false}
}

Fixes #568

@jacobbednarz jacobbednarz changed the base branch from master to 0.14 February 22, 2021 03:25
@jacobbednarz jacobbednarz merged commit d346eb5 into cloudflare:0.14 Feb 22, 2021
@jacobbednarz jacobbednarz deleted the proxied-to-bool-ptr branch February 22, 2021 03:53
dmizelle pushed a commit to dmizelle/external-dns that referenced this pull request Sep 15, 2021
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)

cloudflare/cloudflare-go#595
dmizelle pushed a commit to dmizelle/external-dns that referenced this pull request Sep 15, 2021
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)

cloudflare/cloudflare-go#595
dmizelle pushed a commit to dmizelle/external-dns that referenced this pull request Sep 15, 2021
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
dmizelle pushed a commit to dmizelle/external-dns that referenced this pull request Sep 15, 2021
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 <[email protected]>
dmizelle pushed a commit to dmizelle/external-dns that referenced this pull request Oct 1, 2021
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxied cannot be set to false when updating a DNS record
1 participant