Skip to content

feat!: add summary to coder ping #14762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
add spinner
  • Loading branch information
ethanndickson committed Sep 24, 2024
commit d5bdff0c6fc23b1f6c814e12132eb99dc40fa710
10 changes: 9 additions & 1 deletion cli/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"cdr.dev/slog"
"cdr.dev/slog/sloggers/sloghuman"

"github.com/briandowns/spinner"

"github.com/coder/pretty"

"github.com/coder/coder/v2/cli/cliui"
Expand Down Expand Up @@ -101,6 +103,11 @@ func (r *RootCmd) ping() *serpent.Command {
ctx, cancel := context.WithCancel(inv.Context())
defer cancel()

spin := spinner.New(spinner.CharSets[5], 100*time.Millisecond)
spin.Writer = inv.Stderr
spin.Suffix = pretty.Sprint(cliui.DefaultStyles.Keyword, " Collecting diagnostics...")
spin.Start()

notifyCtx, notifyCancel := inv.SignalNotifyContext(ctx, StopSignals...)
defer notifyCancel()

Expand Down Expand Up @@ -139,7 +146,6 @@ func (r *RootCmd) ping() *serpent.Command {
diagCtx, diagCancel := context.WithTimeout(inv.Context(), 30*time.Second)
defer diagCancel()
diags := conn.GetPeerDiagnostics()
cliui.PeerDiagnostics(inv.Stderr, diags)

// Silent ping to determine whether we should show diags
_, didP2p, _, _ := conn.Ping(ctx)
Expand Down Expand Up @@ -185,6 +191,8 @@ func (r *RootCmd) ping() *serpent.Command {
}
}

spin.Stop()
cliui.PeerDiagnostics(inv.Stderr, diags)
connDiags.Write(inv.Stderr)
results := &pingSummary{
Workspace: workspaceName,
Expand Down
Loading