Closed
Description
from kubebuilder 2.0, generated openapi validation spec is changed. i was able to circumvent this problem by manually patch generated CRD in crd/kustomization.yaml, but i think this one needs fix.
foo_types.go
type FooSpec struct {
// +kubebuilder:validation:Enum=foo;bar;baz
Foos []string `json:"foos"`
}
expected CRD
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: foo.com
spec:
validation:
openAPIV3Schema:
properties:
spec:
properties:
foos:
items:
enum:
- foo
- bar
- baz
type: string
type: array
actual CRD
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: foo.com
spec:
validation:
openAPIV3Schema:
properties:
spec:
properties:
foos:
enum:
- foo
- bar
- baz
items:
type: string
type: array
kustomization.yaml patch
patches:
- patch: |-
- op: replace
path: /spec/validation/openAPIV3Schema/properties/spec/properties/foos
value:
items:
enum:
- foo
- bar
- baz
type: string
type: array
target:
kind: CustomResourceDefinition
name: foo.com