(client *api.Client, repo ghrepo.Interface, runID int64, jobsURL safeurl.SafeURL, attempt uint64)
| 485 | } |
| 486 | |
| 487 | func 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 | |
| 522 | func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) { |
| 523 | path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "jobs", jobID) |
no test coverage detected