-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Type of question
Best practices
General operator-related help
Open question
Question
Is there a way to add a validation for "one of" to the CRDs using the kubebuilder markers (// +kubebuilder:validation..).
Eg:
There are two parts to .spec.options. .spec.options.option1 and .spec.options.option2
User should be able to provide either .spec.options.option1 or .spec.options.option2, not both of them.
Is it possible to do this validation using the kubebuilder markers.
Maybe something like
// +kubebuilder:validation:OneOf=`.spec.options.option1`,`.spec.options.option1`
Environment
Operator type:
/language go
Kubernetes cluster type:
Openshift / Kubernetes
$ operator-sdk version
operator-sdk version: "v1.0.1", commit: "4169b318b578156ed56530f373d328276d040a1b", kubernetes version: "v1.18.2", go version: "go1.13.15 linux/amd64", GOOS: "linux", GOARCH: "amd64"
$ go version (if language is Go)
1.14
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.1+3f6f40d", GitCommit:"3f6f40d", GitTreeState:"clean", BuildDate:"2020-06-08T07:13:25Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}