How to ignore struct fields with controller-gen

476 views
Skip to first unread message

Will Beason

unread,
Nov 12, 2020, 11:28:51 AM11/12/20
to kubeb...@googlegroups.com, Bryce Cronkite-Ratcliff
Hey,

We've got types with fields we do not want to expose to users via the CRD, but that we want to keep around for debug purposes.

```
 // FooLogLevel overrides the logging verbosity for all Foo pods.
// This field is intentionally left hidden/undocumented since it is really only
// used to gather extra logs for support cases.
FooLogLevel int
```

Running controller-gen returns the following error:

```
$ go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd paths=./...
/absolute/path/to/types.go:273:2: encountered struct field "LogLevel" without JSON tag in type "ManagementSpec"
```

We want to keep this field in the struct as it enables us to support customers, but we don't want to expose it to customers outside of support cases (or imply that we will continue to support the field in the future). How do we do this? Is there documentation on this use case?

- Will Beason
Reply all
Reply to author
Forward
0 new messages