MCPcopy Create free account
hub / github.com/cli/cli / pollForPermissions

Method pollForPermissions

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

Source from the content-addressed store, hash-verified

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