From e5ac713b4272752c6631bf36a61b16ace16dd558 Mon Sep 17 00:00:00 2001 From: shi yuhang <52435083+shiyuhang0@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:41:03 +0800 Subject: [PATCH] Optimize create/delete output (#113) --- internal/cli/branch/create.go | 4 ++-- internal/cli/cluster/create.go | 4 ++-- internal/cli/cluster/delete.go | 4 ++-- internal/cli/cluster/delete_test.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/cli/branch/create.go b/internal/cli/branch/create.go index 79825b77..825a43f2 100644 --- a/internal/cli/branch/create.go +++ b/internal/cli/branch/create.go @@ -177,7 +177,7 @@ func CreateAndWaitReady(h *internal.Helper, d cloud.TiDBCloudClient, params *bra for { select { case <-timer: - return errors.New("Timeout waiting for branch to be ready, please check status on dashboard.") + return errors.New(fmt.Sprintf("Timeout waiting for branch %s to be ready, please check status on dashboard.", newBranchID)) case <-ticker.C: clusterResult, err := d.GetBranch(branchApi.NewGetBranchParams(). WithClusterID(params.ClusterID). @@ -209,7 +209,7 @@ func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, params * for { select { case <-timer: - return ui.Result("Timeout waiting for branch to be ready, please check status on dashboard.") + return ui.Result(fmt.Sprintf("Timeout waiting for branch %s to be ready, please check status on dashboard.", newBranchID)) case <-ticker.C: clusterResult, err := d.GetBranch(branchApi.NewGetBranchParams(). WithClusterID(params.ClusterID). diff --git a/internal/cli/cluster/create.go b/internal/cli/cluster/create.go index 07281079..23f813fb 100644 --- a/internal/cli/cluster/create.go +++ b/internal/cli/cluster/create.go @@ -311,7 +311,7 @@ func CreateAndWaitReady(h *internal.Helper, d cloud.TiDBCloudClient, projectID s for { select { case <-timer: - return errors.New("Timeout waiting for cluster to be ready, please check status on dashboard.") + return errors.New(fmt.Sprintf("Timeout waiting for cluster %s to be ready, please check status on dashboard.", newClusterID)) case <-ticker.C: clusterResult, err := d.GetCluster(clusterApi.NewGetClusterParams(). WithClusterID(newClusterID). @@ -343,7 +343,7 @@ func CreateAndSpinnerWait(ctx context.Context, d cloud.TiDBCloudClient, projectI for { select { case <-timer: - return ui.Result("Timeout waiting for cluster to be ready, please check status on dashboard.") + return ui.Result(fmt.Sprintf("Timeout waiting for cluster %s to be ready, please check status on dashboard.", newClusterID)) case <-ticker.C: clusterResult, err := d.GetCluster(clusterApi.NewGetClusterParams(). WithClusterID(newClusterID). diff --git a/internal/cli/cluster/delete.go b/internal/cli/cluster/delete.go index eb43151e..a24ae8e2 100644 --- a/internal/cli/cluster/delete.go +++ b/internal/cli/cluster/delete.go @@ -166,14 +166,14 @@ func DeleteCmd(h *internal.Helper) *cobra.Command { for { select { case <-timer: - return errors.New("timeout waiting for deleting cluster, please check status on dashboard") + return errors.New(fmt.Sprintf("timeout waiting for deleting cluster %s, please check status on dashboard", clusterID)) case <-ticker.C: _, err := d.GetCluster(clusterApi.NewGetClusterParams(). WithClusterID(clusterID). WithProjectID(projectID)) if err != nil { if _, ok := err.(*clusterApi.GetClusterNotFound); ok { - fmt.Fprintln(h.IOStreams.Out, color.GreenString("cluster deleted")) + fmt.Fprintln(h.IOStreams.Out, color.GreenString(fmt.Sprintf("cluster %s deleted", clusterID))) return nil } return errors.Trace(err) diff --git a/internal/cli/cluster/delete_test.go b/internal/cli/cluster/delete_test.go index 97644da7..98f58482 100644 --- a/internal/cli/cluster/delete_test.go +++ b/internal/cli/cluster/delete_test.go @@ -74,7 +74,7 @@ func (suite *DeleteClusterSuite) TestDeleteClusterArgs() { { name: "delete cluster success", args: []string{"--project-id", projectID, "--cluster-id", clusterID, "--force"}, - stdoutString: "cluster deleted\n", + stdoutString: fmt.Sprintf("cluster %s deleted\n", clusterID), }, { name: "delete cluster without force", @@ -84,7 +84,7 @@ func (suite *DeleteClusterSuite) TestDeleteClusterArgs() { { name: "delete cluster with output flag", args: []string{"-p", projectID, "-c", clusterID, "--force"}, - stdoutString: "cluster deleted\n", + stdoutString: fmt.Sprintf("cluster %s deleted\n", clusterID), }, { name: "delete cluster without required project id",