From d14289a40c6fed3909e1686e48d40acef4df8b8e Mon Sep 17 00:00:00 2001 From: Manabu McCloskey Date: Wed, 20 Nov 2024 13:30:07 -0800 Subject: [PATCH] print url for codespaces (#456) 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 +}