From 4e7733877536545c443c7b3b2a12241e6c25452e Mon Sep 17 00:00:00 2001 From: Manabu McCloskey Date: Wed, 20 Nov 2024 20:26:55 +0000 Subject: [PATCH] print url for codespaces Signed-off-by: Manabu McCloskey --- pkg/cmd/create/root.go | 43 ++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index 32212ccd..1e2ff4b9 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/url" + "os" "path/filepath" "strings" @@ -160,18 +161,7 @@ func create(cmd *cobra.Command, args []string) error { return err } - subDomain := "argocd." - subPath := "" - - if pathRouting == true { - subDomain = "" - subPath = "argocd" - } - - fmt.Print("\n\n########################### Finished Creating IDP Successfully! ############################\n\n\n") - fmt.Printf("Can Access ArgoCD at %s\nUsername: admin\n", fmt.Sprintf("%s://%s%s:%s/%s", protocol, subDomain, host, port, subPath)) - fmt.Print(`Password can be retrieved by running: idpbuilder get secrets -p argocd`, "\n") - + printSuccessMsg() return nil } @@ -224,3 +214,32 @@ func getPackageCustomFile(input string) (v1alpha1.PackageCustomization, error) { FilePath: paths[0], }, nil } + +func printSuccessMsg() { + subDomain := "argocd." + subPath := "" + + if pathRouting == true { + subDomain = "" + subPath = "argocd" + } + + var argoURL string + + proxy := behindProxy() + if proxy { + argoURL = fmt.Sprintf("https://%s/argocd", host) + } else { + argoURL = fmt.Sprintf("%s://%s%s:%s/%s", protocol, subDomain, host, port, subPath) + } + + fmt.Print("\n\n########################### Finished Creating IDP Successfully! ############################\n\n\n") + fmt.Printf("Can Access ArgoCD at %s\nUsername: admin\n", argoURL) + fmt.Print(`Password can be retrieved by running: idpbuilder get secrets -p argocd`, "\n") +} + +func behindProxy() bool { + // check if we are in codespaces: https://docs.github.com/en/codespaces/developing-in-a-codespace/default-environment-variables-for-your-codespace + _, ok := os.LookupEnv("CODESPACES") + return ok +}