Skip to content

Commit

Permalink
Fix-migrate (#723)
Browse files Browse the repository at this point in the history
## 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
<!-- Add any additional notes here -->
  • Loading branch information
ATGardner authored Nov 14, 2023
1 parent 752b573 commit c614f06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.52
VERSION=v0.1.53

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
10 changes: 9 additions & 1 deletion cmd/commands/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit c614f06

Please sign in to comment.