Skip to content

Commit

Permalink
Optimize create/delete output (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Aug 15, 2023
1 parent 11556aa commit e5ac713
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/cli/branch/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cluster/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cluster/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit e5ac713

Please sign in to comment.