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

Method pollForPermissions

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

Source from the content-addressed store, hash-verified

419}
420
421func (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

Callers 1

Calls 4

RunWithProgressMethod · 0.95
DoneMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected