From c614f06708c4e743c14315978897885305ddb017 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Tue, 14 Nov 2023 14:55:42 +0200 Subject: [PATCH] Fix-migrate (#723) ## What delete argocd-initial-admin-secret ## Why after a new runtime is installed using helm, a new initial-admin-secret will be created by argocd ## Notes --- Makefile | 2 +- cmd/commands/migrate.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a96c9c64..ec429f8d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.1.52 +VERSION=v0.1.53 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/cmd/commands/migrate.go b/cmd/commands/migrate.go index f8e97e45..33c5a00b 100644 --- a/cmd/commands/migrate.go +++ b/cmd/commands/migrate.go @@ -474,7 +474,6 @@ func addPathToClusterApp(destFs apfs.FS, runtimeName, clusterName, path string) addPathToInclude(app, path) bytes, err := yaml.Marshal(app) bytes = filterStatus(bytes) - fmt.Println(string(bytes)) if err != nil { return err } @@ -531,6 +530,11 @@ func removeFromCluster(ctx context.Context, runtimeNamespace, kubeContext string return fmt.Errorf("failed updating argoproj CRDs: %w", err) } + err = deleteInitialAdminSecret(ctx, kubeFactory, runtimeNamespace) + if err != nil { + return fmt.Errorf("failed deleting initial-admin-secret: %w", err) + } + return nil } @@ -589,6 +593,10 @@ func patchCrds(ctx context.Context, kubeFactory apkube.Factory) error { return nil } +func deleteInitialAdminSecret(ctx context.Context, kubeFactory apkube.Factory, namespace string) error { + return kube.GetClientSetOrDie(kubeFactory).CoreV1().Secrets(namespace).Delete(ctx, "argocd-initial-admin-secret", metav1.DeleteOptions{}) +} + func getLabelPatch(value string) string { return fmt.Sprintf(`{ "metadata": { "labels": { "%s": "%s" } } }`, apstore.Default.LabelKeyAppManagedBy, value) }