(ctx context.Context, createParams *api.CreateCodespaceParams)
| 419 | } |
| 420 | |
| 421 | func (a *App) pollForPermissions(ctx context.Context, createParams *api.CreateCodespaceParams) error { |
| 422 | return a.RunWithProgress("Waiting for permissions to be accepted in the browser", func() (err error) { |
| 423 | ctx, cancel := context.WithTimeout(ctx, permissionsPollingTimeout) |
| 424 | defer cancel() |
| 425 | |
| 426 | done := make(chan error, 1) |
| 427 | go func() { |
| 428 | for { |
| 429 | accepted, err := a.apiClient.GetCodespacesPermissionsCheck(ctx, createParams.RepositoryID, createParams.Branch, createParams.DevContainerPath) |
| 430 | if err != nil { |
| 431 | done <- err |
| 432 | return |
| 433 | } |
| 434 | |
| 435 | if accepted { |
| 436 | done <- nil |
| 437 | return |
| 438 | } |
| 439 | |
| 440 | // Wait before polling again |
| 441 | time.Sleep(permissionsPollingInterval) |
| 442 | } |
| 443 | }() |
| 444 | |
| 445 | select { |
| 446 | case err := <-done: |
| 447 | return err |
| 448 | case <-ctx.Done(): |
| 449 | return fmt.Errorf("timed out waiting for permissions to be accepted in the browser") |
| 450 | } |
| 451 | }) |
| 452 | } |
| 453 | |
| 454 | // showStatus polls the codespace for a list of post create states and their status. It will keep polling |
| 455 | // until all states have finished. Once all states have finished, we poll once more to check if any new |
no test coverage detected