From 57b8cf8fb465fd0168e1d87547f13fdb9a104fa6 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 27 Nov 2024 19:33:18 +0800 Subject: [PATCH] fix(tenant): fixed validation for tenant restore --- api/v1alpha1/obtenant_webhook.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/obtenant_webhook.go b/api/v1alpha1/obtenant_webhook.go index 6358e0f3a..29d88016b 100644 --- a/api/v1alpha1/obtenant_webhook.go +++ b/api/v1alpha1/obtenant_webhook.go @@ -290,9 +290,9 @@ func (r *OBTenant) validateMutation() error { if r.Spec.Source != nil && r.Spec.Source.Restore != nil { res := r.Spec.Source.Restore - if res.ArchiveSource == nil && res.BakDataSource == nil && res.SourceUri == "" { + if (res.ArchiveSource == nil || res.BakDataSource == nil) && res.SourceUri == "" { allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("source").Child("restore"), res, "Restore must have a source option, but both archiveSource, bakDataSource and sourceUri are nil now")) - } else { + } else if res.ArchiveSource != nil && res.BakDataSource != nil { destErrs := errors.Join( validateBackupDestination(cluster, res.ArchiveSource, "spec", "source", "restore", "archiveSource"), validateBackupDestination(cluster, res.BakDataSource, "spec", "source", "restore", "bakDataSource"),