ns1-go
ns1-go copied to clipboard
Unable to disable TSIG on a secondary zone
If TSIG is enabled on a secondary zone, it can't be disabled through this library because the field zone.Secondary.TSIG.Enabled
is tagged with json:"omitempty"
, so it will never be serialized to JSON if it's false.
This code will reproduce:
zone := dns.NewZone("secondary.test")
zone.MakeSecondary("1.2.3.4")
zone.Secondary.TSIG = &dns.TSIG{
Enabled: true,
Key: "abc123",
Name: "test",
Hash: "hmac-sha512",
}
client.Zones.Create(zone)
zone.Secondary.TSIG.Enabled = false
client.Zones.Update(zone)
// zone still has TSIG enabled
👋 Hi @acm1 - Thanks for submitting this issue and the PR.
Based on past experience with adjusting omitempty
tags, we'll just want to get the PR tested against our Terraform provider prior to merging to see if this creates any unexpected behavior that we'll need to handle on that end.
I've created a ticket in our backlog to cover that and we'll circle back once that's complete.
As commented on #96, we think the best way to address this is to switch the type of the Enabled
field to *bool
. This allows the field to be set to true
and false
, but can still be omitted if a value is not provided.
As modifying the type of this field is a breaking change, this will be included in the next major version of this SDK. We're currently scoping what other changes we want to package into a major release and will update with a timeline soon.
@mburtless , I'm working in the TSIG support for Go SDK and Terraform and found this issue too. I didn't notice the issue was already reported so I did the workaround removing the omitempty
tag. With this, if zone.Secondary.TSIG.Enable isn't defined, its default value is false
, and in terraform, this field would be Required, so I don't see any problems in this workaround. What do you think?
Desired functionality has been available for a while as per above comment. Closing.