Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Print instruction after teardown #403

Merged
merged 6 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService
return nil, err
}
fmt.Printf("Existing details of your sandbox")
util.PrintSandboxMessage(consolePort, docker.Kubeconfig, sandboxConfig.DryRun)
util.PrintSandboxStartMessage(consolePort, docker.Kubeconfig, sandboxConfig.DryRun)
return nil, nil
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandbox
if err != nil {
return err
}
util.PrintDemoMessage(util.DemoConsolePort, docker.Kubeconfig, sandboxConfig.DryRun)
util.PrintDemoStartMessage(util.DemoConsolePort, docker.Kubeconfig, sandboxConfig.DryRun)
return nil
}

Expand All @@ -444,6 +444,6 @@ func StartSandboxCluster(ctx context.Context, args []string, sandboxConfig *sand
if err != nil {
return err
}
util.PrintSandboxMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig, sandboxConfig.DryRun)
util.PrintSandboxStartMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig, sandboxConfig.DryRun)
return nil
}
2 changes: 2 additions & 0 deletions pkg/sandbox/teardown.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sandbox
import (
"context"
"fmt"
"github.com/flyteorg/flytectl/pkg/util"

"github.com/docker/docker/api/types"
"github.com/enescakir/emoji"
Expand Down Expand Up @@ -38,6 +39,7 @@ func Teardown(ctx context.Context, cli docker.Docker, teardownFlags *sandboxCmdC
}

fmt.Printf("%v %v Sandbox cluster is removed successfully.\n", emoji.Broom, emoji.Broom)
util.PrintSandboxTeardownMessage(util.SandBoxConsolePort, docker.SandboxKubeconfig)
return nil
}

Expand Down
26 changes: 21 additions & 5 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ func SetupFlyteDir() error {
return nil
}

// PrintDemoMessage will print sandbox success message
// PrintDemoMessage will print demo start success message
// Deprecated: use PrintDemoStartMessage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are confident this is not used by any potential users, it is fine to delete.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt that there's someone out there importing this. It's fine to delete.

func PrintDemoMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
PrintDemoStartMessage(flyteConsolePort, kubeconfigLocation, dryRun)
}

// PrintDemoStartMessage will print demo start success message
func PrintDemoStartMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
kubeconfig := strings.Join([]string{
"$KUBECONFIG",
kubeconfigLocation,
Expand All @@ -84,10 +90,9 @@ func PrintDemoMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bo
successMsg = fmt.Sprintf("%v http://localhost:%v/console", ProgressSuccessMessagePending, flyteConsolePort)
} else {
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)
fmt.Printf("%v Run the following command to export sandbox environment variables for accessing flytectl\n", emoji.Sparkle)
fmt.Printf("%v Run the following command to export demo environment variables for accessing flytectl\n", emoji.Sparkle)
fmt.Printf(" export FLYTECTL_CONFIG=%v \n", configutil.FlytectlConfig)
if dryRun {
fmt.Printf("%v Run the following command to export kubeconfig variables for accessing flyte pods locally\n", emoji.Sparkle)
Expand All @@ -97,8 +102,14 @@ func PrintDemoMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bo
fmt.Printf("%s The Minio API is hosted on localhost:30002. Use http://localhost:30080/minio/login for Minio console\n", emoji.OpenFileFolder)
}

// PrintSandboxMessage will print sandbox success message
// PrintSandboxMessage will print sandbox start success message
// Deprecated: use PrintSandboxStartMessage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

func PrintSandboxMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
PrintSandboxStartMessage(flyteConsolePort, kubeconfigLocation, dryRun)
}

// PrintSandboxStartMessage will print sandbox start success message
func PrintSandboxStartMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
kubeconfig := strings.Join([]string{
"$KUBECONFIG",
kubeconfigLocation,
Expand All @@ -109,7 +120,6 @@ func PrintSandboxMessage(flyteConsolePort int, kubeconfigLocation string, dryRun
successMsg = fmt.Sprintf("%v http://localhost:%v/console", ProgressSuccessMessagePending, flyteConsolePort)
} else {
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)
fmt.Printf("%v Run the following command to export sandbox environment variables for accessing flytectl\n", emoji.Sparkle)
Expand All @@ -120,6 +130,12 @@ func PrintSandboxMessage(flyteConsolePort int, kubeconfigLocation string, dryRun
}
}

// PrintSandboxTeardownMessage will print sandbox teardown success message
func PrintSandboxTeardownMessage(flyteConsolePort int, kubeconfigLocation string) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we don't need an equivalent for demo command because demo teardown invokes sandbox.Teardown()

fmt.Printf("%v Run the following command to unset sandbox environment variables for accessing flytectl\n", emoji.Sparkle)
fmt.Printf(" unset FLYTECTL_CONFIG \n")
}

// SendRequest will create request and return the response
func SendRequest(method, url string, option io.Reader) (*http.Response, error) {
client := &http.Client{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestSetupFlyteDir(t *testing.T) {

func TestPrintSandboxMessage(t *testing.T) {
t.Run("Print Sandbox Message", func(t *testing.T) {
PrintSandboxMessage(SandBoxConsolePort, docker.SandboxKubeconfig, false)
PrintSandboxStartMessage(SandBoxConsolePort, docker.SandboxKubeconfig, false)
})
}

Expand Down