Skip to content

Commit

Permalink
Print instruction after teardown (flyteorg#403)
Browse files Browse the repository at this point in the history
* Print instruction after teardown

Signed-off-by: Hongxin Liang <[email protected]>

* Add unit test

Signed-off-by: Hongxin Liang <[email protected]>

* Fix import

Signed-off-by: Hongxin Liang <[email protected]>

* Delete unused functions

Signed-off-by: Hongxin Liang <[email protected]>

* Try fixing doc build

Signed-off-by: Hongxin Liang <[email protected]>

* Name

Signed-off-by: Hongxin Liang <[email protected]>

---------

Signed-off-by: Hongxin Liang <[email protected]>
  • Loading branch information
honnix authored May 17, 2023
1 parent 3ae90aa commit b8ee84f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion flytectl/doc-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ sphinx-material
sphinx-code-include
sphinx-copybutton
sphinx_fontawesome
sphinxcontrib-yt
sphinxcontrib-youtube
sphinx-panels
2 changes: 1 addition & 1 deletion flytectl/doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
sphinxcontrib-yt==0.2.2
sphinxcontrib-youtube==1.2.0
# via -r doc-requirements.in
text-unidecode==1.3
# via python-slugify
Expand Down
2 changes: 1 addition & 1 deletion flytectl/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"sphinx-prompt",
"sphinx_copybutton",
"sphinx_fontawesome",
"sphinxcontrib.yt",
"sphinxcontrib.youtube",
"sphinx_panels",
]

Expand Down
6 changes: 3 additions & 3 deletions flytectl/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 flytectl/pkg/sandbox/teardown.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/flyteorg/flytectl/pkg/configutil"
"github.com/flyteorg/flytectl/pkg/docker"
"github.com/flyteorg/flytectl/pkg/k8s"
"github.com/flyteorg/flytectl/pkg/util"
)

func Teardown(ctx context.Context, cli docker.Docker, teardownFlags *sandboxCmdConfig.TeardownFlags) error {
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
18 changes: 11 additions & 7 deletions flytectl/pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func SetupFlyteDir() error {
return nil
}

// PrintDemoMessage will print sandbox success message
func PrintDemoMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
// 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 +84,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 +96,8 @@ 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
func PrintSandboxMessage(flyteConsolePort int, kubeconfigLocation string, dryRun bool) {
// 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 +108,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 +118,12 @@ func PrintSandboxMessage(flyteConsolePort int, kubeconfigLocation string, dryRun
}
}

// PrintSandboxTeardownMessage will print sandbox teardown success message
func PrintSandboxTeardownMessage(flyteConsolePort int, kubeconfigLocation string) {
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
10 changes: 8 additions & 2 deletions flytectl/pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ func TestSetupFlyteDir(t *testing.T) {
assert.Nil(t, SetupFlyteDir())
}

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

func TestPrintSandboxTeardownMessage(t *testing.T) {
t.Run("Print Sandbox Message", func(t *testing.T) {
PrintSandboxTeardownMessage(SandBoxConsolePort, docker.SandboxKubeconfig)
})
}

Expand Down

0 comments on commit b8ee84f

Please sign in to comment.