Skip to content

Commit

Permalink
Use cmd.Context()
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Feb 5, 2024
1 parent a5008c2 commit d432e65
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tools/pd-ctl/pdctl/command/cluster_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

package command

import (
"context"

"github.com/spf13/cobra"
)
import "github.com/spf13/cobra"

// NewClusterCommand return a cluster subcommand of rootCmd
func NewClusterCommand() *cobra.Command {
Expand All @@ -42,7 +38,7 @@ func NewClusterStatusCommand() *cobra.Command {
}

func showClusterCommandFunc(cmd *cobra.Command, _ []string) {
info, err := PDCli.GetCluster(context.Background())
info, err := PDCli.GetCluster(cmd.Context())
if err != nil {
cmd.Printf("Failed to get the cluster information: %s\n", err)
return
Expand All @@ -51,7 +47,7 @@ func showClusterCommandFunc(cmd *cobra.Command, _ []string) {
}

func showClusterStatusCommandFunc(cmd *cobra.Command, _ []string) {
status, err := PDCli.GetClusterStatus(context.Background())
status, err := PDCli.GetClusterStatus(cmd.Context())
if err != nil {
cmd.Printf("Failed to get the cluster status: %s\n", err)
return
Expand Down

0 comments on commit d432e65

Please sign in to comment.