From 6f014e5ce7ff79686e3c2494cc03e172cfe5c031 Mon Sep 17 00:00:00 2001 From: zychen5186 Date: Thu, 21 Mar 2024 22:03:37 -0700 Subject: [PATCH] Add ENV VAR FLTYE_ADMIN_ENDPOINT (#4948) Signed-off-by: zychen5186 --- cmd/core/cmd.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmd/core/cmd.go b/cmd/core/cmd.go index 2d00adc0..10cd8255 100644 --- a/cmd/core/cmd.go +++ b/cmd/core/cmd.go @@ -3,12 +3,15 @@ package cmdcore import ( "context" "fmt" + "net/url" + "os" "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "github.com/flyteorg/flyte/flyteidl/clients/go/admin" + stdConfig "github.com/flyteorg/flyte/flytestdlib/config" "github.com/flyteorg/flytectl/cmd/config" "github.com/flyteorg/flytectl/pkg/pkce" @@ -66,6 +69,18 @@ func generateCommandFunc(cmdEntry CommandEntry) func(cmd *cobra.Command, args [] } adminCfg := admin.GetConfig(ctx) + + if len(os.Getenv("FLTYE_ADMIN_ENDPOINT")) > 0 { + envEndpoint, err := url.Parse(os.Getenv("FLTYE_ADMIN_ENDPOINT")) + if err != nil { + fmt.Println("Error parsing URL:", err) + return err + } + adminCfg.Endpoint = stdConfig.URL{ + URL: *envEndpoint, + } + } + if len(adminCfg.Endpoint.String()) == 0 { return cmdEntry.CmdFunc(ctx, args, CommandContext{}) }