cloudflare / cloudflare-go

The official Go library for the Cloudflare API
https://developers.cloudflare.com/api
BSD 3-Clause "New" or "Revised" License
1.46k stars 579 forks source link

SRV record creation unsuccessful #1110

Closed ChefMood closed 1 year ago

ChefMood commented 1 year ago

Confirmation

cloudflare-go version

latest

Go environment

GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/moody.sasson/Library/Caches/go-build" GOENV="/Users/moody.sasson/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/moody.sasson/go/pkg/mod" GONOPROXY="none" GONOSUMDB="css.com" GOOS="darwin" GOPATH="/Users/moody.sasson/go" GOPRIVATE="css.com" GOPROXY="https://proxy.golang.org,https://artifactory.cssvpn.com/artifactory/api/go/go,direct" GOROOT="/opt/homebrew/Cellar/go/1.19.2/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.2/libexec/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19.2" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/30/fqp04lsd1mb6g5yw6hc2xhc40000gq/T/go-build2271358378=/tmp/go-build -gno-record-gcc-switches -fno-common"

Expected output

Not clear if this is really a defect or unclear API/Doc. I am trying to figure out how to use Cloudflare DNS GO API Client to configure an SRV entry.

Referring to:

// DNSRecord represents a DNS record in a zone. type DNSRecord struct { CreatedOn time.Time json:"created_on,omitempty" ModifiedOn time.Time json:"modified_on,omitempty" Type string json:"type,omitempty" Name string json:"name,omitempty" Content string json:"content,omitempty" Meta interface{} json:"meta,omitempty" Data interface{} json:"data,omitempty" // data returned by: SRV, LOC ID string json:"id,omitempty" ZoneID string json:"zone_id,omitempty" ZoneName string json:"zone_name,omitempty" Priority uint16 json:"priority,omitempty" TTL int json:"ttl,omitempty" Proxied bool json:"proxied,omitempty" Proxiable bool json:"proxiable,omitempty" Locked bool json:"locked,omitempty" }

Can someone please detail what needs to go where? A code sample would be great; I was looking around and could not fine a reference. Thank you

Actual output

Trying different combinations, the server returns vague DNS validation error

Code demonstrating the issue

// val is of type DNSRecord

val.Type = "SRV" val.Name = _xxx._tls.dom.xyz m := make(map[string]string) m["weight"] = "111" m["port"] = "2345" m["target"] = "foo.bar" m["service"] = "_xxx" m["proto"] = "_tls" m["priority"] = "10" m["name"] = "somename" val.Data = m val.Content = "" val.Proxiable = false *val.Proxied = false val.Priority = nil

The above is only one sample. Tried and errored different combinations.

Steps to reproduce

Simple issue DNS record create request

References

Source code.

jacobbednarz commented 1 year ago

here is a brief example. Data is a map of the complex DNS values.

record, err := api.CreateDNSRecord(ctx, zoneID, cloudflare.DNSRecord{
        Name: "_xmpp-client._tcp.zlkgojffod",
        Type: "SRV",
        Data: map[string]interface{}{
            "name":     "zlkgojffod.terraform.cfapi.net",
            "port":     5222,
            "priority": 5,
            "proto":    "_tcp",
            "service":  "_xmpp-client",
            "target":   "talk.l.google.com",
            "weight":   0,
        },
        TTL: 30,
    })