Skip to content
Closed
Changes from all commits
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
9 changes: 8 additions & 1 deletion tool/tctl/common/top/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,18 @@ func (c *Command) newMetricsClient(ctx context.Context) (string, MetricsClient,
}

// TryRun attempts to run subcommands.
func (c *Command) TryRun(ctx context.Context, cmd string, _ commonclient.InitFunc) (match bool, err error) {
func (c *Command) TryRun(ctx context.Context, cmd string, clientFunc commonclient.InitFunc) (match bool, err error) {
if cmd != c.top.FullCommand() {
return false, nil
}

// Call clientFunc to init `c.config`
_, closeFn, err := clientFunc(ctx)
if err != nil {
return true, trace.Wrap(err)
}
closeFn(ctx)

addr, metricsClient, err := c.newMetricsClient(ctx)
if err != nil {
return true, trace.Wrap(err)
Expand Down
Loading