controller-tools: markers to skip fields that does not have json tags for crd generation
controller-tools
version: 0.2.2
Currently I am getting this error after upgrading controller-tools from 0.2.2 from 0.1.9 because in our CRD status we included a go struct URL
(https://github.com/knative/pkg/blob/43ca049cdbdad4892b0c926e7c6536d064efde72/apis/duck/v1beta1/addressable_types.go#L40) which does not have json tags and this blocks generating the crd manifests.
/usr/local/go/src/net/url/url.go:357:2: encountered struct field "Scheme" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:358:2: encountered struct field "Opaque" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:359:2: encountered struct field "User" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:360:2: encountered struct field "Host" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:361:2: encountered struct field "Path" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:362:2: encountered struct field "RawPath" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:363:2: encountered struct field "ForceQuery" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:364:2: encountered struct field "RawQuery" without JSON tag in type "URL"
/usr/local/go/src/net/url/url.go:365:2: encountered struct field "Fragment" without JSON tag in type "URL"
We want a way to skip fields when generating crd manifests.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 28 (17 by maintainers)
Commits related to this issue
- Generate schema for types implementing custom JSON marshaling as Any type Currently controller-gen complains about structs with missing json tags even when those structs implement custom JSON marshal... — committed to skaslev/controller-tools by deleted user 4 years ago
- Generate schema for types with custom JSON marshaling as Any type Currently controller-gen complains about structs with missing json tags even when those structs implement custom JSON marshalling. W... — committed to skaslev/controller-tools by deleted user 4 years ago
Like yuzisun, I’m trying to add a field of type
net.URL
to my CRD. In other projects, I’ve wanted to use fields of typetime.Time
andtime.Duration
. After doing a bit of digging, I stumbled acrossmetav1.Time
andmetav1.Duration
. These types seem to do exactly what’s wanted here. Does anyone know how? I’ve tried wrapping a type aroundnet.URL
with custom serialization, but haven’t had much successBefore the revert, you could do something like
Which would get interpreted as:
So it supported cases where you don’t want an object or you just want a catch-all object, but didn’t support cases where you want a partially-specified object, or a fully specified object, which was an oversight.
For whatever we merge, we should attempt to support both usecases.