MCPcopy Index your code
hub / github.com/coder/coder / ping

Method ping

cli/ping.go:81–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81func (r *RootCmd) ping() *serpent.Command {
82 var (
83 pingNum int64
84 pingTimeout time.Duration
85 pingWait time.Duration
86 pingTimeLocal bool
87 pingTimeUTC bool
88 )
89
90 cmd := &serpent.Command{
91 Annotations: workspaceCommand,
92 Use: "ping <workspace>",
93 Short: "Ping a workspace",
94 Middleware: serpent.Chain(
95 serpent.RequireNArgs(1),
96 ),
97 Handler: func(inv *serpent.Invocation) error {
98 client, err := r.InitClient(inv)
99 if err != nil {
100 return err
101 }
102 ctx, cancel := context.WithCancel(inv.Context())
103 defer cancel()
104 appearanceConfig := initAppearance(ctx, client)
105 notifyCtx, notifyCancel := inv.SignalNotifyContext(ctx, StopSignals...)
106 defer notifyCancel()
107
108 workspaceName := inv.Args[0]
109 _, workspaceAgent, _, err := GetWorkspaceAndAgent(
110 ctx, inv, client,
111 false, // Do not autostart for a ping.
112 workspaceName,
113 )
114 if err != nil {
115 return err
116 }
117
118 // Start spinner after any build logs have finished streaming
119 spin := spinner.New(spinner.CharSets[5], 100*time.Millisecond)
120 spin.Writer = inv.Stderr
121 spin.Suffix = pretty.Sprint(cliui.DefaultStyles.Keyword, " Collecting diagnostics...")
122 if !r.verbose {
123 spin.Start()
124 }
125
126 opts := &workspacesdk.DialAgentOptions{}
127
128 if r.verbose {
129 opts.Logger = inv.Logger.AppendSinks(sloghuman.Sink(inv.Stdout)).Leveled(slog.LevelDebug)
130 }
131
132 if r.disableDirect {
133 opts.BlockEndpoints = true
134 }
135 if !r.disableNetworkTelemetry {
136 opts.EnableTelemetry = true
137 }
138 wsClient := workspacesdk.New(client)

Callers 1

CoreSubcommandsMethod · 0.95

Calls 15

InitClientMethod · 0.95
StatusCodeMethod · 0.95
WriteMethod · 0.95
addResultMethod · 0.95
WriteMethod · 0.95
NewFunction · 0.92
FetchAWSIPRangesFunction · 0.92
RunInterfacesReportFunction · 0.92
PeerDiagnosticsFunction · 0.92
initAppearanceFunction · 0.85
GetWorkspaceAndAgentFunction · 0.85
isAWSIPFunction · 0.85

Tested by

no test coverage detected