pollWhile polls the agent while the condition is true. It fetches the agent on each iteration and returns the updated agent when the condition is false, the context is canceled, or an error occurs.
(ctx context.Context, agent codersdk.WorkspaceAgent, cond func(agent codersdk.WorkspaceAgent) bool)
| 353 | // on each iteration and returns the updated agent when the condition is false, |
| 354 | // the context is canceled, or an error occurs. |
| 355 | func (aw *agentWaiter) pollWhile(ctx context.Context, agent codersdk.WorkspaceAgent, cond func(agent codersdk.WorkspaceAgent) bool) (codersdk.WorkspaceAgent, error) { |
| 356 | var err error |
| 357 | for cond(agent) { |
| 358 | agent, err = aw.fetchAgent(ctx) |
| 359 | if err != nil { |
| 360 | return agent, xerrors.Errorf("fetch: %w", err) |
| 361 | } |
| 362 | } |
| 363 | if err = ctx.Err(); err != nil { |
| 364 | return agent, err |
| 365 | } |
| 366 | return agent, nil |
| 367 | } |
| 368 | |
| 369 | func troubleshootingMessage(agent codersdk.WorkspaceAgent, url string) string { |
| 370 | m := "For more information and troubleshooting, see " + url |
no test coverage detected