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

Function GetJobs

pkg/cmd/run/shared/shared.go:487–520  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, runID int64, jobsURL safeurl.SafeURL, attempt uint64)

Source from the content-addressed store, hash-verified

485}
486
487func GetJobs(client *api.Client, repo ghrepo.Interface, runID int64, jobsURL safeurl.SafeURL, attempt uint64) ([]Job, error) {
488 var jobsPath safeurl.SafeURL
489 if attempt > 0 {
490 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", strconv.FormatInt(runID, 10), "attempts", strconv.FormatUint(attempt, 10), "jobs")
491 if err != nil {
492 return nil, err
493 }
494 p.SetQuery("per_page", "100")
495 jobsPath = p
496 } else {
497 u, err := url.Parse(jobsURL.String())
498 if err != nil {
499 return nil, err
500 }
501 query := url.Values{}
502 query.Set("per_page", "100")
503 u.RawQuery = query.Encode()
504 // Since u is derived from jobsURL, an already-trusted safeurl.SafeURL, the resulting URL is safe to declare as such.
505 jobsPath = safeurl.NewImmutableSafeURL(u.String())
506 }
507
508 // A non-nil empty slice is returned so callers can tell that jobs were fetched and there are none (if len is zero).
509 jobs := []Job{}
510 for jobsPath.String() != "" {
511 var resp JobsPayload
512 next, err := client.RESTWithNext(repo.RepoHost(), http.MethodGet, jobsPath.String(), nil, &resp)
513 if err != nil {
514 return nil, err
515 }
516 jobs = append(jobs, resp.Jobs...)
517 jobsPath = safeurl.NewImmutableSafeURL(next)
518 }
519 return jobs, nil
520}
521
522func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) {
523 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "jobs", jobID)

Callers 2

runViewFunction · 0.92
renderRunFunction · 0.92

Calls 9

StringMethod · 0.95
JoinPathFunction · 0.92
NewImmutableSafeURLFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
SetMethod · 0.65
RESTWithNextMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected