MCPcopy
hub / github.com/cli/cli / pollForPermissions

Method pollForPermissions

pkg/cmd/codespace/create.go:416–447  ·  view source on GitHub ↗
(ctx context.Context, createParams *api.CreateCodespaceParams)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

RunWithProgressMethod · 0.95
DoneMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected