From 3420f430739ac8518c83cd3b23bf6a8e42b411f7 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Fri, 9 May 2025 11:29:38 +0200 Subject: [PATCH] feat: forbid usage of `.spec.configuration.serverName` in ObjectStore (#336) Closes #334 Signed-off-by: Marco Nenciarini --- api/v1/objectstore_types.go | 1 + config/crd/bases/barmancloud.cnpg.io_objectstores.yaml | 5 +++++ manifest.yaml | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/api/v1/objectstore_types.go b/api/v1/objectstore_types.go index a028adf..0b15d71 100644 --- a/api/v1/objectstore_types.go +++ b/api/v1/objectstore_types.go @@ -38,6 +38,7 @@ type InstanceSidecarConfiguration struct { // ObjectStoreSpec defines the desired state of ObjectStore. type ObjectStoreSpec struct { // The configuration for the barman-cloud tool suite + // +kubebuilder:validation:XValidation:rule="!has(self.serverName)",fieldPath=".serverName",reason="FieldValueForbidden",message="use the 'serverName' plugin parameter in the Cluster resource" Configuration barmanapi.BarmanObjectStoreConfiguration `json:"configuration"` // RetentionPolicy is the retention policy to be used for backups diff --git a/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml b/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml index c957bf4..fe9b170 100644 --- a/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml +++ b/config/crd/bases/barmancloud.cnpg.io_objectstores.yaml @@ -382,6 +382,11 @@ spec: required: - destinationPath type: object + x-kubernetes-validations: + - fieldPath: .serverName + message: use the 'serverName' plugin parameter in the Cluster resource + reason: FieldValueForbidden + rule: '!has(self.serverName)' instanceSidecarConfiguration: description: The configuration for the sidecar that runs in the instance pods diff --git a/manifest.yaml b/manifest.yaml index a87c2d4..26094d6 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -381,6 +381,11 @@ spec: required: - destinationPath type: object + x-kubernetes-validations: + - fieldPath: .serverName + message: use the 'serverName' plugin parameter in the Cluster resource + reason: FieldValueForbidden + rule: '!has(self.serverName)' instanceSidecarConfiguration: description: The configuration for the sidecar that runs in the instance pods