-
Notifications
You must be signed in to change notification settings - Fork 460
Open
Description
In the following scenario of embedding an external struct the generated applyconfiguration does not compile:
controller-tools versions: v0.19.0, main @ bf7d6b7
api/v1/foo_types.go:
type FooSpec struct {
corev1.LocalObjectReference `json:",inline"`
}api/v1/applyconfiguration/api/v1/foospec.go:
func (b *FooSpecApplyConfiguration) WithName(value string) *FooSpecApplyConfiguration {
b.LocalObjectReference.Name = &value
return b
}Error: Cannot use '&value' (type *string) as the type string
Without embedding it works on first glance:
api/v1/foo_types.go:
type FooSpec struct {
Ref corev1.LocalObjectReference `json:",inline"`
}api/v1/applyconfiguration/api/v1/foospec.go:
func (b *FooSpecApplyConfiguration) WithRef(value v1.LocalObjectReference) *FooSpecApplyConfiguration {
b.Ref = &value
return b
}However, this combination of not embedding the field but using json:",inline" (to keep the previous CRD schema) generates undesired content when marshaling the spec with encoding/json, as json:",inline" is ignored, making the kube-apiserver emit the warning unknown field "spec.Ref"
Metadata
Metadata
Assignees
Labels
No labels