From ffb81357ef8d66d415b65ae62838b3abd5a2438f Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 9 Nov 2023 11:43:24 +0100 Subject: [PATCH] networkfence: make parameters as immutable mark parameters as immutable once created which means we are not able to add/delete or update the parameters once created. Signed-off-by: Madhu Rajanna --- apis/csiaddons/v1alpha1/networkfence_types.go | 1 + config/crd/bases/csiaddons.openshift.io_networkfences.yaml | 3 +++ deploy/controller/crds.yaml | 3 +++ 3 files changed, 7 insertions(+) diff --git a/apis/csiaddons/v1alpha1/networkfence_types.go b/apis/csiaddons/v1alpha1/networkfence_types.go index 8c82b692e..2bf9b478c 100644 --- a/apis/csiaddons/v1alpha1/networkfence_types.go +++ b/apis/csiaddons/v1alpha1/networkfence_types.go @@ -56,6 +56,7 @@ type SecretSpec struct { } // NetworkFenceSpec defines the desired state of NetworkFence +// +kubebuilder:validation:XValidation:rule="has(self.parameters) == has(oldSelf.parameters)",message="parameters are immutable" type NetworkFenceSpec struct { // Driver contains the name of CSI driver. // +kubebuilder:validation:Required diff --git a/config/crd/bases/csiaddons.openshift.io_networkfences.yaml b/config/crd/bases/csiaddons.openshift.io_networkfences.yaml index 3234ca5fd..32d788a37 100644 --- a/config/crd/bases/csiaddons.openshift.io_networkfences.yaml +++ b/config/crd/bases/csiaddons.openshift.io_networkfences.yaml @@ -105,6 +105,9 @@ spec: - driver - fenceState type: object + x-kubernetes-validations: + - message: parameters are immutable + rule: has(self.parameters) == has(oldSelf.parameters) status: description: NetworkFenceStatus defines the observed state of NetworkFence properties: diff --git a/deploy/controller/crds.yaml b/deploy/controller/crds.yaml index 25ff230b0..3e3777107 100644 --- a/deploy/controller/crds.yaml +++ b/deploy/controller/crds.yaml @@ -213,6 +213,9 @@ spec: - driver - fenceState type: object + x-kubernetes-validations: + - message: parameters are immutable + rule: has(self.parameters) == has(oldSelf.parameters) status: description: NetworkFenceStatus defines the observed state of NetworkFence properties: