diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index ba5b60b09..9d694ea79 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -1364,7 +1364,7 @@ func runK3d(cmd *cobra.Command, args []string) error { "app.kubernetes.io/instance", "argo", "argo", - 600, + 1200, ) if err != nil { log.Error().Msgf("Error finding argo workflows Deployment: %s", err) @@ -1376,11 +1376,6 @@ func runK3d(cmd *cobra.Command, args []string) error { return err } - // Mark cluster install as complete - telemetry.SendEvent(segClient, telemetry.ClusterInstallCompleted, "") - viper.Set("kubefirst-checks.cluster-install-complete", true) - viper.WriteConfig() - // Set flags used to track status of active options helpers.SetClusterStatusFlags(k3d.CloudProvider, config.GitProvider) @@ -1417,6 +1412,11 @@ func runK3d(cmd *cobra.Command, args []string) error { log.Error().Err(err).Msg("") } + // Mark cluster install as complete + telemetry.SendEvent(segClient, telemetry.ClusterInstallCompleted, "") + viper.Set("kubefirst-checks.cluster-install-complete", true) + viper.WriteConfig() + log.Info().Msg("kubefirst installation complete") log.Info().Msg("welcome to your new kubefirst platform running in K3d") time.Sleep(time.Second * 1) // allows progress bars to finish diff --git a/cmd/k3d/destroy.go b/cmd/k3d/destroy.go index d86319bb4..fe4ad3773 100644 --- a/cmd/k3d/destroy.go +++ b/cmd/k3d/destroy.go @@ -13,6 +13,7 @@ import ( "strings" "time" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/runtime/pkg" gitlab "github.com/kubefirst/runtime/pkg/gitlab" "github.com/kubefirst/runtime/pkg/helpers" @@ -30,11 +31,13 @@ func destroyK3d(cmd *cobra.Command, args []string) error { // Determine if there are active installs gitProvider := viper.GetString("flags.git-provider") + clusterName := viper.GetString("flags.cluster-name") gitProtocol := viper.GetString("flags.git-protocol") - // _, err := helpers.EvalDestroy(k3d.CloudProvider, gitProvider) - // if err != nil { - // return err - // } + + if clusterName == "" { + fmt.Printf("Your kubefirst platform running has been already destroyed.") + progress.Progress.Quit() + } // Check for existing port forwards before continuing err := k8s.CheckForExistingPortForwards(9000) @@ -49,7 +52,6 @@ func destroyK3d(cmd *cobra.Command, args []string) error { log.Info().Msg("destroying kubefirst platform running in k3d") - clusterName := viper.GetString("flags.cluster-name") atlantisWebhookURL := fmt.Sprintf("%s/events", viper.GetString("ngrok.host")) // Switch based on git provider, set params @@ -240,6 +242,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error { viper.Set("kbot", "") viper.Set("kubefirst-checks", "") viper.Set("kubefirst", "") + viper.Set("flags", "") viper.WriteConfig() } @@ -251,6 +254,7 @@ func destroyK3d(cmd *cobra.Command, args []string) error { } time.Sleep(time.Millisecond * 200) // allows progress bars to finish fmt.Printf("Your kubefirst platform running in %s has been destroyed.", k3d.CloudProvider) + progress.Progress.Quit() return nil } diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index c6e5d5188..be088aef5 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -201,6 +201,10 @@ func ExportCluster(cluster apiTypes.Cluster, kcfg *k8s.KubernetesClient) error { cluster.Status = "provisioned" cluster.InProgress = false + if viper.GetBool("kubefirst-checks.secret-export-state") { + return nil + } + time.Sleep(time.Second * 10) payload, err := json.Marshal(cluster) @@ -223,5 +227,8 @@ func ExportCluster(cluster apiTypes.Cluster, kcfg *k8s.KubernetesClient) error { return errors.New(fmt.Sprintf("unable to save secret to management cluster. %s", err)) } + viper.Set("kubefirst-checks.secret-export-state", true) + viper.WriteConfig() + return nil }