@@ -27,6 +27,7 @@ import (
2727 "sync"
2828 "time"
2929
30+ kubeutil "github.com/codefresh-io/cli-v2/pkg/util/kube"
3031 routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing"
3132
3233 "github.com/codefresh-io/cli-v2/pkg/log"
@@ -500,6 +501,7 @@ func runRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
500501
501502 // check whether the runtime exists
502503 var err error
504+
503505 if ! opts .SkipChecks {
504506 _ , err = getRuntime (ctx , opts .RuntimeName )
505507 }
@@ -575,12 +577,33 @@ func runRuntimeUninstall(ctx context.Context, opts *RuntimeUninstallOptions) err
575577 cfConfig .GetCurrentContext ().DefaultRuntime = ""
576578 }
577579
580+ err = runPostUninstallCleanup (ctx , opts .KubeFactory , opts .RuntimeName )
581+ if err != nil {
582+ return fmt .Errorf ("failed to do post uninstall cleanup: %w" , err )
583+ }
584+
578585 uninstallDoneStr := fmt .Sprintf ("Done uninstalling runtime \" %s\" " , opts .RuntimeName )
579586 appendLogToSummary (uninstallDoneStr , nil )
580587
581588 return nil
582589}
583590
591+ func runPostUninstallCleanup (ctx context.Context , kubeFactory kube.Factory , namespace string ) error {
592+ secrets , err := kubeutil .GetSecretsWithLabel (ctx , kubeFactory , namespace , store .Get ().LabelSelectorSealedSecret )
593+ if err != nil {
594+ return err
595+ }
596+
597+ for _ , secret := range secrets .Items {
598+ err = kubeutil .DeleteSecretWithFinalizer (ctx , kubeFactory , & secret )
599+ if err != nil {
600+ log .G ().Warn ("failed to delete secret: %w" , err )
601+ }
602+ }
603+
604+ return nil
605+ }
606+
584607func printApplicationsState (ctx context.Context , runtime string , f kube.Factory , managed bool ) error {
585608 if managed {
586609 return nil
0 commit comments