From 5e3731bc46a751ef3ebed903e2b2b61756bd9829 Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Mon, 27 Nov 2023 10:05:07 +0100 Subject: [PATCH] fix(secret): do not delete secret if cannot find (#140) Signed-off-by: Wen Zhou (cherry picked from commit 60f04190d8cfbcc374a116580f8fd54219f77f56) --- components/dashboard/dashboard.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/dashboard/dashboard.go b/components/dashboard/dashboard.go index 1027077c1c9..0722c2900de 100644 --- a/components/dashboard/dashboard.go +++ b/components/dashboard/dashboard.go @@ -295,9 +295,10 @@ func (d *Dashboard) cleanOauthClient(cli client.Client, dscispec *dsciv1.DSCInit if !apierrs.IsNotFound(err) { return fmt.Errorf("error getting secret %s: %w", name, err) } - } - if err := cli.Delete(context.TODO(), oauthClientSecret); err != nil { - return fmt.Errorf("error deleting secret %s in namespace %s : %w", name, dscispec.ApplicationsNamespace, err) + } else { + if err := cli.Delete(context.TODO(), oauthClientSecret); err != nil { + return fmt.Errorf("error deleting secret %s in namespace %s : %w", name, dscispec.ApplicationsNamespace, err) + } } } return nil