-
Notifications
You must be signed in to change notification settings - Fork 683
Description
Confirm this is a Go library issue and not an underlying Cloudflare API issue
- This is an issue with the Go library
Describe the bug
I have an existing CNAME record sample.apps.io that points to aaaaa.elb.us-east-1.amazonaws.com and Im trying to update the contents to point to a new load balancer when --name is fully qualified for flarectl dns create-or-update.
To Reproduce
The following attempt fails with:
$ flarectl dns create-or-update --proxy --zone apps.io --name sample.apps.io --content bbbbb.elb.us-east-1.amazonaws.com --type CNAME
Error creating DNS record: An A, AAAA, or CNAME record with that host already exists. For more details, refer to <https://developers.cloudflare.com/dns/manage-dns-records/troubleshooting/records-with-same-name/>. (81053)
flarectl is trying to
createthe record instead ofupdateit if you look at the error meessage.
It seems that because the flag --name sample.apps.io is fully qualified instead of short --name sample this gets concatentated preemptively:
cloudflare-go/cmd/flarectl/dns.go
Line 86 in 57714bf
| records, _, err := api.ListDNSRecords(context.Background(), cloudflare.ZoneIdentifier(zoneID), cloudflare.ListDNSRecordsParams{Name: name + "." + zone}) |
sample.apps.io.apps.io) to update and causes the create to fail instead since its still using what was passed in by --name: cloudflare-go/cmd/flarectl/dns.go
Line 117 in 57714bf
| Name: name, |
Ive noticed some inconsistency with --name for the CLI dns subcommands. flarectl dns list has differing results for FQDN vs short:
flarectl dns list FQDN:
$ flarectl dns list --zone apps.io --type CNAME --name sample.apps.io
ID | TYPE | NAME | CONTENT | PROXIED | TTL
-----------------------------------+-------+------------------------------+-------------------------------------------------------------------------------+---------+------
id123456 | CNAME | sample.apps.io | aaaaa.elb.us-east-1.amazonaws.com | true | 1
flarectl dns list short:
$ flarectl dns list --zone apps.io --type CNAME --name sample
ID | TYPE | NAME | CONTENT | PROXIED | TTL
-----+------+------+---------+---------+------
create and update dns subcommands will handle both FQDN and short. Heres the result of update:
$ flarectl dns update --id id123456 --proxy --zone apps.io --name sample.apps.io --content bbbbb.elb.us-east-1.amazonaws.com --type CNAME
$cloudinfra flarectl dns update --id id123456 --proxy --zone apps.io --name sample --content cccccc.elb.us-east-1.amazonaws.com --type CNAME
Nothing is returned but records update as expected
Suggestion
flarectl should have consistent behavior across the various dns subcommands consumption of --name. It seems like supporting both FQDN and short for --name for create-or-update and list would ensure it doesnt break existing behavior.
OS
macOS
Go version
Go 1.22.0
Library version
github.com/cloudflare/cloudflare-go/v0.115.0