From 440ad3171f187867be35b916851ad81936b8e91a Mon Sep 17 00:00:00 2001 From: pmahindrakar-oss Date: Sat, 23 Apr 2022 00:23:03 +0530 Subject: [PATCH] Demo fit and finish (#317) Signed-off-by: Prafulla Mahindrakar --- flytectl/cmd/demo/start.go | 6 +++--- flytectl/pkg/configutil/configutil.go | 5 +++++ flytectl/pkg/configutil/configutil_test.go | 1 + flytectl/pkg/util/util.go | 13 +++++++++---- flytectl/pkg/util/util_test.go | 6 ++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/flytectl/cmd/demo/start.go b/flytectl/cmd/demo/start.go index 2ee48d9a0f..893bdce116 100644 --- a/flytectl/cmd/demo/start.go +++ b/flytectl/cmd/demo/start.go @@ -164,7 +164,7 @@ func startDemoCluster(ctx context.Context, args []string, cmdCtx cmdCore.Command return err } primeFlytekitPod(ctx, k8sClient.CoreV1().Pods("default")) - util.PrintSandboxMessage(util.DemoConsolePort) + util.PrintDemoMessage(util.DemoConsolePort) } return nil } @@ -186,7 +186,7 @@ func startDemo(ctx context.Context, cli docker.Docker, reader io.Reader) (*bufio return nil, err } fmt.Printf("Existing details of your demo cluster") - util.PrintSandboxMessage(util.DemoConsolePort) + util.PrintDemoMessage(util.DemoConsolePort) return nil, nil } @@ -198,7 +198,7 @@ func startDemo(ctx context.Context, cli docker.Docker, reader io.Reader) (*bufio Host: "localhost:30081", Insecure: true, } - if err := configutil.SetupConfig(configutil.FlytectlConfig, configutil.GetSandboxTemplate(), templateValues); err != nil { + if err := configutil.SetupConfig(configutil.ConfigFile, configutil.GetDemoTemplate(), templateValues); err != nil { return nil, err } diff --git a/flytectl/pkg/configutil/configutil.go b/flytectl/pkg/configutil/configutil.go index c0df7f9b31..cedad69146 100644 --- a/flytectl/pkg/configutil/configutil.go +++ b/flytectl/pkg/configutil/configutil.go @@ -65,6 +65,11 @@ func GetSandboxTemplate() string { return AdminConfigTemplate + StorageConfigTemplate } +// GetDemoTemplate return demo cluster config +func GetDemoTemplate() string { + return AdminConfigTemplate +} + // GetAWSCloudTemplate return aws Flyte config with storage config func GetAWSCloudTemplate() string { return AdminConfigTemplate + StorageS3ConfigTemplate diff --git a/flytectl/pkg/configutil/configutil_test.go b/flytectl/pkg/configutil/configutil_test.go index 6908f06144..e79964af18 100644 --- a/flytectl/pkg/configutil/configutil_test.go +++ b/flytectl/pkg/configutil/configutil_test.go @@ -52,4 +52,5 @@ func TestAwsConfig(t *testing.T) { assert.Equal(t, AdminConfigTemplate+StorageS3ConfigTemplate, GetAWSCloudTemplate()) assert.Equal(t, AdminConfigTemplate+StorageGCSConfigTemplate, GetGoogleCloudTemplate()) assert.Equal(t, AdminConfigTemplate+StorageConfigTemplate, GetSandboxTemplate()) + assert.Equal(t, AdminConfigTemplate, GetDemoTemplate()) } diff --git a/flytectl/pkg/util/util.go b/flytectl/pkg/util/util.go index a34aeba5c4..091ea21707 100644 --- a/flytectl/pkg/util/util.go +++ b/flytectl/pkg/util/util.go @@ -5,16 +5,15 @@ import ( "io" "io/ioutil" "net/http" - "os" "strings" - hversion "github.com/hashicorp/go-version" - - "github.com/enescakir/emoji" "github.com/flyteorg/flytectl/pkg/configutil" "github.com/flyteorg/flytectl/pkg/docker" f "github.com/flyteorg/flytectl/pkg/filesystemutils" + + "github.com/enescakir/emoji" + hversion "github.com/hashicorp/go-version" ) const ( @@ -66,6 +65,12 @@ func PrintSandboxMessage(flyteConsolePort int) { fmt.Printf("export FLYTECTL_CONFIG=%v \n", configutil.FlytectlConfig) } +// PrintDemoMessage will print demo success message +func PrintDemoMessage(flyteConsolePort int) { + successMsg := fmt.Sprintf("%v http://localhost:%v/console", ProgressSuccessMessage, flyteConsolePort) + fmt.Printf("%v %v %v %v %v \n", emoji.ManTechnologist, successMsg, emoji.Rocket, emoji.Rocket, emoji.PartyPopper) +} + // SendRequest will create request and return the response func SendRequest(method, url string, option io.Reader) (*http.Response, error) { client := &http.Client{} diff --git a/flytectl/pkg/util/util_test.go b/flytectl/pkg/util/util_test.go index 718a244d9c..ebf67a902d 100644 --- a/flytectl/pkg/util/util_test.go +++ b/flytectl/pkg/util/util_test.go @@ -29,6 +29,12 @@ func TestPrintSandboxMessage(t *testing.T) { }) } +func TestPrintDemoMessage(t *testing.T) { + t.Run("Print Demo Message", func(t *testing.T) { + PrintDemoMessage(DemoConsolePort) + }) +} + func TestSendRequest(t *testing.T) { t.Run("Successful get request", func(t *testing.T) { response, err := SendRequest("GET", "https://github.com", nil)