-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Bug Report
// WorkloadSpec defines the desired state of Workload
type FooSpec struct {
FooTemplate appsv1.DeploymentSpec `json:"fooTemplate,omitempty"`
}
type Foo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec FooSpec `json:"spec,omitempty"`
Status FooStatus `json:"status,omitempty"`
}
Here FooTemplate is of type DeploymentSpec which contains a ObjectMeta in its PodTemplateSpec.
In the generated CRD yaml, PodTemplateSpec.ObjectMeta is turned-out as type object

When the CR is applied of type Foo, with foo.Spec.fooTemplate.template.metadata.labels` set as follows

following error is seen
error when creating "foo-cr.yaml": Foo in version "v1alpha1" cannot be handled as a Foo: strict decoding error: unknown field "spec.fooTemplate.template.metadata.labels"
What did you do?
Performed as described above
What did you expect to see?
CR of type Foo with '"spec.fooTemplate.template.metadata.labels"applied to cluster without an issue
What did you see instead? Under which circumstances?
Environment
Operator type:
/language go
Kubernetes cluster type:
minikube
$ operator-sdk version
operator-sdk version: "v1.22.2", commit: "da3346113a8a75e11225f586482934000504a60f", kubernetes version: "1.24.1", go version: "go1.18.4", GOOS: "linux", GOARCH: "amd64"
$ go version (if language is Go)
go version go1.20.6 linux/amd64
$ kubectl version
Client Version: v1.28.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.4