cloudflare / cloudflare-go

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

How to fill a DeleteRulesetRuleParams #2885

Closed tlimoncelli closed 1 month ago

tlimoncelli commented 1 month ago

Confirmation

cloudflare-go version

v0.101.1-0.20240809030210-5dc300a49857

Go environment

GO111MODULE=''
GOARCH='arm64'
GOBIN='/Users/tlimoncelli/bin'
GOCACHE='/Users/tlimoncelli/Library/Caches/go-build'
GOENV='/Users/tlimoncelli/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tlimoncelli/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tlimoncelli/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/tlimoncelli/tmp/cloudflare-go/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/lx/4w8fz8z916g911yvplhy6jjc0000gp/T/go-build1864510889=/tmp/go-build -gno-record-gcc-switches -fno-common'

Expected output

In https://github.com/cloudflare/cloudflare-go/pull/2833. the type DeleteRulesetRuleParams struct was added:

type DeleteRulesetRuleParams struct {
    rulesetID     string `json:"-"`
    rulesetRuleID string `json:"-"`
}

How does one instantiate this struct? The fields are unexported.

We tried this:

  p := cloudflare.DeleteRulesetRuleParams{cfr.SRRRulesetID, cfr.SRRRulesetRuleID}
  err := c.cfClient.DeleteRulesetRule(context.Background(), cloudflare.ZoneIdentifier(domainID), p)

but Go complains:

$ go build
# github.com/StackExchange/dnscontrol/v4/providers/cloudflare
providers/cloudflare/rest.go:391:42: implicit assignment to unexported field rulesetID in struct literal of type "github.com/cloudflare/cloudflare-go".DeleteRulesetRuleParams
providers/cloudflare/rest.go:391:60: implicit assignment to unexported field rulesetRuleID in struct literal of type "github.com/cloudflare/cloudflare-go".DeleteRulesetRuleParams

I feel like I'm missing something. Should the fields me exported or is there a constructor I'm unaware of? The other *Params structs export all their fields.

Thanks!

CC jacobbednarz for visibility.

Actual output

see above

Code demonstrating the issue

  p := cloudflare.DeleteRulesetRuleParams{cfr.SRRRulesetID, cfr.SRRRulesetRuleID}
  err := c.cfClient.DeleteRulesetRule(context.Background(), cloudflare.ZoneIdentifier(domainID), p)

Steps to reproduce

see above

References

No response

tlimoncelli commented 1 month ago

On the assumption that the fields should have been exported, I've created https://github.com/cloudflare/cloudflare-go/pull/2886 for your consideration.

Thanks!