From 569f8292acdc271df7ed7b1935b98a7612a36167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3rebe=20-=20Romain=20GERARD?= Date: Wed, 22 May 2024 09:39:06 +0200 Subject: [PATCH] Update cluster install cli --- cmd/cluster_install.go | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/cmd/cluster_install.go b/cmd/cluster_install.go index 9c8c65b6..a084b0e7 100644 --- a/cmd/cluster_install.go +++ b/cmd/cluster_install.go @@ -27,7 +27,6 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } client := utils.GetQoveryClient(tokenType, token) @@ -38,37 +37,46 @@ var clusterInstallCmd = &cobra.Command{ // if Local Machine, quit and print message to use the `qovery demo up` on the local machine utils.Println("Cluster Type:") clusterTypePrompt := promptui.Select{ - Label: "Select where you want to install Qovery on:", - Items: []string{"Your Kubernetes Cluster", "Your Local Machine"}, + Label: "Select where you want to install Qovery on", + Items: []string{ + "Your AWS Cluster", + "Your GCP Cluster", + "Your Scaleway Cluster", + "Your own Kubernetes Cluster", + "Your Local Machine", + }, } _, kubernetesType, err := clusterTypePrompt.Run() - if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } - if kubernetesType == "Local Machine" { + cloudProviderType := qovery.CLOUDPROVIDERENUM_AWS + if strings.Contains(kubernetesType, "AWS") { + cloudProviderType = qovery.CLOUDPROVIDERENUM_AWS + } else if strings.Contains(kubernetesType, "GCP") { + cloudProviderType = qovery.CLOUDPROVIDERENUM_GCP + } else if strings.Contains(kubernetesType, "Scaleway") { + cloudProviderType = qovery.CLOUDPROVIDERENUM_SCW + } else if strings.Contains(kubernetesType, "Local Machine") { utils.PrintlnInfo("Please use `qovery demo up` to create a demo cluster on your local machine") os.Exit(0) + } else { + cloudProviderType = qovery.CLOUDPROVIDERENUM_ON_PREMISE } // if Self Managed, continue with the installation process - organization, err := utils.SelectOrganization() - if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } if organization == nil { utils.PrintlnError(fmt.Errorf("organizations not found, please create one on https://console.qovery.com")) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } // check that the cluster name is unique @@ -77,12 +85,11 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } var selfManagedClusters []qovery.Cluster for _, cluster := range clusters.GetResults() { - if cluster.CloudProvider == qovery.CLOUDPROVIDERENUM_ON_PREMISE { + if *cluster.Kubernetes == qovery.KUBERNETESENUM_SELF_MANAGED && cluster.CloudProvider == cloudProviderType { selfManagedClusters = append(selfManagedClusters, cluster) } } @@ -102,7 +109,6 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } if reuseOrCreateNewCluster == "Reuse a Cluster" { @@ -124,7 +130,6 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } cluster = utils.FindByClusterName(selfManagedClusters, reuseClusterName) @@ -153,7 +158,6 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } kubernetesTypeOther := "" @@ -168,7 +172,6 @@ var clusterInstallCmd = &cobra.Command{ if err != nil { utils.PrintlnError(err) os.Exit(1) - panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011 } kubernetesTypeOther = kubernetesType @@ -209,7 +212,7 @@ var clusterInstallCmd = &cobra.Command{ } // API call to create the self-managed cluster and link it to the on-premise account - description := fmt.Sprintf("Cluster running on %s (%s)", kubernetesType, kubernetesTypeOther) + description := fmt.Sprintf("Cluster running on %s (%s)", cloudProviderType, kubernetesTypeOther) k := qovery.KUBERNETESENUM_SELF_MANAGED cp := qovery.CLOUDPROVIDERENUM_ON_PREMISE