From 751e556e4ea40410825400727b308f825400b95a Mon Sep 17 00:00:00 2001 From: Gianni Carafa Date: Fri, 25 Oct 2024 13:11:10 +0200 Subject: [PATCH] Update prompt messages for better clarity and user interaction. --- cmd/kuberoCli/install.go | 144 +++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 68 deletions(-) diff --git a/cmd/kuberoCli/install.go b/cmd/kuberoCli/install.go index a6c4b46..46b031b 100644 --- a/cmd/kuberoCli/install.go +++ b/cmd/kuberoCli/install.go @@ -261,7 +261,7 @@ func installOLM() { return } - olmInstall := promptLine("2) Install OLM", "[y,n]", "n") + olmInstall := promptLine("2) Install OLM (optional)", "[y,n]", "n") if olmInstall != "y" { install_olm = false return @@ -354,7 +354,7 @@ func installIngress() { return } - ingressInstall := promptLine("4) Install Ingress", "[y,n]", "y") + ingressInstall := promptLine("4) Install Nginx Ingress", "[y,n]", "y") if ingressInstall != "y" { return } else { @@ -495,6 +495,8 @@ func installKuberoUi() { createNamespace("kubero") + gitops := promptLine("Enable GitOps Feature", "[y,n]", "n") + kuberoSecretInstalled, _ := exec.Command("kubectl", "get", "secret", "kubero-secrets", "-n", "kubero").Output() if len(kuberoSecretInstalled) > 0 { cfmt.Println("{{✓ Kubero Secret exists}}::lightGreen") @@ -527,53 +529,56 @@ func installKuberoUi() { "--from-literal=KUBERO_USERS="+userDBencoded, ) - githubConfigure := promptLine("Configure Github", "[y,n]", "y") - githubPersonalAccessToken := "" - if githubConfigure == "y" { - githubPersonalAccessToken = promptLine("Github personal access token", "", "") - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITHUB_PERSONAL_ACCESS_TOKEN="+githubPersonalAccessToken) - } + if gitops == "y" { - giteaConfigure := promptLine("Configure Gitea", "[y,n]", "n") - giteaPersonalAccessToken := "" - giteaBaseUrl := "" - if giteaConfigure == "y" { - giteaPersonalAccessToken = promptLine("Gitea personal access token", "", "") - giteaBaseUrl = promptLine("Gitea URL", "http://localhost:3000", "") - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITEA_PERSONAL_ACCESS_TOKEN="+giteaPersonalAccessToken) - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITEA_BASEURL="+giteaBaseUrl) - } + githubConfigure := promptLine("Configure Github", "[y,n]", "n") + githubPersonalAccessToken := "" + if githubConfigure == "y" { + githubPersonalAccessToken = promptLine("Github personal access token", "", "") + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITHUB_PERSONAL_ACCESS_TOKEN="+githubPersonalAccessToken) + } - gogsConfigure := promptLine("Configure Gogs", "[y,n]", "n") - gogsPersonalAccessToken := "" - gogsBaseUrl := "" - if gogsConfigure == "y" { - gogsPersonalAccessToken = promptLine("Gogs personal access token", "", "") - gogsBaseUrl = promptLine("Gogs URL", "http://localhost:3000", "") - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GOGS_PERSONAL_ACCESS_TOKEN="+gogsPersonalAccessToken) - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GOGS_BASEURL="+gogsBaseUrl) - } + giteaConfigure := promptLine("Configure Gitea", "[y,n]", "n") + giteaPersonalAccessToken := "" + giteaBaseUrl := "" + if giteaConfigure == "y" { + giteaPersonalAccessToken = promptLine("Gitea personal access token", "", "") + giteaBaseUrl = promptLine("Gitea URL", "http://localhost:3000", "") + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITEA_PERSONAL_ACCESS_TOKEN="+giteaPersonalAccessToken) + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITEA_BASEURL="+giteaBaseUrl) + } - gitlabConfigure := promptLine("Configure Gitlab", "[y,n]", "n") - gitlabPersonalAccessToken := "" - gitlabBaseUrl := "" - if gitlabConfigure == "y" { - gitlabPersonalAccessToken = promptLine("Gitlab personal access token", "", "") - gitlabBaseUrl = promptLine("Gitlab URL", "http://localhost:3080", "") - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITLAB_PERSONAL_ACCESS_TOKEN="+gitlabPersonalAccessToken) - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITLAB_BASEURL="+gitlabBaseUrl) - } + gogsConfigure := promptLine("Configure Gogs", "[y,n]", "n") + gogsPersonalAccessToken := "" + gogsBaseUrl := "" + if gogsConfigure == "y" { + gogsPersonalAccessToken = promptLine("Gogs personal access token", "", "") + gogsBaseUrl = promptLine("Gogs URL", "http://localhost:3000", "") + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GOGS_PERSONAL_ACCESS_TOKEN="+gogsPersonalAccessToken) + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GOGS_BASEURL="+gogsBaseUrl) + } - bitbucketConfigure := promptLine("Configure Bitbucket", "[y,n]", "n") - bitbucketUsername := "" - bitbucketAppPassword := "" - if bitbucketConfigure == "y" { - bitbucketUsername = promptLine("Bitbucket Username", "", "") - bitbucketAppPassword = promptLine("Bitbucket App Password", "", "") - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=BITBUCKET_USERNAME="+bitbucketUsername) - createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=BITBUCKET_APP_PASSWORD="+bitbucketAppPassword) - } + gitlabConfigure := promptLine("Configure Gitlab", "[y,n]", "n") + gitlabPersonalAccessToken := "" + gitlabBaseUrl := "" + if gitlabConfigure == "y" { + gitlabPersonalAccessToken = promptLine("Gitlab personal access token", "", "") + gitlabBaseUrl = promptLine("Gitlab URL", "http://localhost:3080", "") + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITLAB_PERSONAL_ACCESS_TOKEN="+gitlabPersonalAccessToken) + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=GITLAB_BASEURL="+gitlabBaseUrl) + } + + bitbucketConfigure := promptLine("Configure Bitbucket", "[y,n]", "n") + bitbucketUsername := "" + bitbucketAppPassword := "" + if bitbucketConfigure == "y" { + bitbucketUsername = promptLine("Bitbucket Username", "", "") + bitbucketAppPassword = promptLine("Bitbucket App Password", "", "") + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=BITBUCKET_USERNAME="+bitbucketUsername) + createSecretCommand.Args = append(createSecretCommand.Args, "--from-literal=BITBUCKET_APP_PASSWORD="+bitbucketAppPassword) + } + } createSecretCommand.Args = append(createSecretCommand.Args, "-n", "kubero") _, kuberoErr := createSecretCommand.Output() @@ -629,39 +634,42 @@ func installKuberoUi() { } } - kuberoUIRegistry := promptLine("Enable Buildpipeline for Kubero (BETA)", "[y/n]", "n") - if kuberoUIRegistry == "y" { - kuberoUIConfig.Spec.Registry.Enabled = true + if gitops == "y" { - kuberoUICreateRegistry := promptLine("Create a local Registry for Kubero", "[y/n]", "n") - if kuberoUICreateRegistry == "y" { - kuberoUIConfig.Spec.Registry.Create = true + kuberoUIRegistry := promptLine("Enable Buildpipeline for Kubero (BETA)", "[y/n]", "n") + if kuberoUIRegistry == "y" { + kuberoUIConfig.Spec.Registry.Enabled = true - kuberoUIRegistryStorage := promptLine("Registry storage size", "", "10Gi") - kuberoUIConfig.Spec.Registry.Storage = kuberoUIRegistryStorage + kuberoUICreateRegistry := promptLine("Create a local Registry for Kubero", "[y/n]", "n") + if kuberoUICreateRegistry == "y" { + kuberoUIConfig.Spec.Registry.Create = true - storageClassList := getAvailableStorageClasses() + kuberoUIRegistryStorage := promptLine("Registry storage size", "", "10Gi") + kuberoUIConfig.Spec.Registry.Storage = kuberoUIRegistryStorage - kuberoUIRegistryStorageClassName := selectFromList("Registry storage class", storageClassList, "") - kuberoUIConfig.Spec.Registry.StorageClassName = kuberoUIRegistryStorageClassName - } + storageClassList := getAvailableStorageClasses() + + kuberoUIRegistryStorageClassName := selectFromList("Registry storage class", storageClassList, "") + kuberoUIConfig.Spec.Registry.StorageClassName = kuberoUIRegistryStorageClassName + } - kuberoUIRegistryHost := promptLine("Registry", "[registry.kubero.mydomain.com]", "") - kuberoUIConfig.Spec.Registry.Host = kuberoUIRegistryHost + kuberoUIRegistryHost := promptLine("Registry", "[registry.kubero.mydomain.com]", "") + kuberoUIConfig.Spec.Registry.Host = kuberoUIRegistryHost - kuberoUIRegistrySubpath := promptLine("Subpath (optional) ", "[example/foo/bar]", "") - kuberoUIConfig.Spec.Registry.Subpath = kuberoUIRegistrySubpath + kuberoUIRegistrySubpath := promptLine("Subpath (optional) ", "[example/foo/bar]", "") + kuberoUIConfig.Spec.Registry.Subpath = kuberoUIRegistrySubpath - kuberoUIConfig.Spec.Registry.Port = 443 + kuberoUIConfig.Spec.Registry.Port = 443 - kuberoUIRegistryUsername := promptLine("Registry username", "", "admin") - kuberoUIConfig.Spec.Registry.Account.Username = kuberoUIRegistryUsername + kuberoUIRegistryUsername := promptLine("Registry username", "", "admin") + kuberoUIConfig.Spec.Registry.Account.Username = kuberoUIRegistryUsername - kuberoUIRegistryPassword := promptLine("Registry password", "", generateRandomString(12, "")) - kuberoUIConfig.Spec.Registry.Account.Password = kuberoUIRegistryPassword + kuberoUIRegistryPassword := promptLine("Registry password", "", generateRandomString(12, "")) + kuberoUIConfig.Spec.Registry.Account.Password = kuberoUIRegistryPassword - kuberoUIRegistryPasswordBytes, _ := bcrypt.GenerateFromPassword([]byte(kuberoUIRegistryPassword), 14) - kuberoUIConfig.Spec.Registry.Account.Hash = string(kuberoUIRegistryPasswordBytes) + kuberoUIRegistryPasswordBytes, _ := bcrypt.GenerateFromPassword([]byte(kuberoUIRegistryPassword), 14) + kuberoUIConfig.Spec.Registry.Account.Hash = string(kuberoUIRegistryPasswordBytes) + } } kuberoUIAudit := promptLine("Enable Audit Logging", "[y/n]", "n") @@ -872,7 +880,7 @@ func installMonitoring() { func installCertManager() { - install := promptLine("6) Install SSL Certmanager", "[y,n]", "y") + install := promptLine("6) Install SSL Cert Manager", "[y,n]", "y") if install != "y" { return }