From 3feaab6b5de541babf3d695d8d6774534af8068a Mon Sep 17 00:00:00 2001 From: chlins Date: Tue, 11 Jan 2022 17:27:51 +0800 Subject: [PATCH] fix: adjust the update logic of deprecated configmap day2 configuration Signed-off-by: chlins --- controllers/goharbor/configuration/cm_reconciler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/controllers/goharbor/configuration/cm_reconciler.go b/controllers/goharbor/configuration/cm_reconciler.go index 15bd42bc0..e084cf551 100644 --- a/controllers/goharbor/configuration/cm_reconciler.go +++ b/controllers/goharbor/configuration/cm_reconciler.go @@ -148,10 +148,17 @@ func (r *CmReconciler) createOrUpdateHarborConfiguration(ctx context.Context, hc if err != nil { if apierrors.IsNotFound(err) { // create hc + r.Log.Info("Create HarborConfiguration", "hc", hc) + return r.Client.Create(ctx, hc) } } - // hc exist - return r.Client.Update(ctx, hc) + // if hc exist, update it + new := old.DeepCopy() + new.Spec = hc.Spec + + r.Log.Info("Update HarborConfiguration", "hc", new) + + return r.Client.Update(ctx, new) }