fetchJobSessionURL tries to return the agent session URL for a job. If the pull request is not yet available, ("", nil) is returned.
(ctx context.Context, client capi.CapiClient, repo ghrepo.Interface, job *capi.Job, bo backoff.BackOff)
| 207 | // fetchJobSessionURL tries to return the agent session URL for a job. If the pull |
| 208 | // request is not yet available, ("", nil) is returned. |
| 209 | func fetchJobSessionURL(ctx context.Context, client capi.CapiClient, repo ghrepo.Interface, job *capi.Job, bo backoff.BackOff) (string, error) { |
| 210 | if job.PullRequest != nil && job.PullRequest.Number > 0 { |
| 211 | // Return the agent session URL if we happen to get it. |
| 212 | // Right now, this never happens. |
| 213 | return agentSessionWebURL(repo, job), nil |
| 214 | } |
| 215 | |
| 216 | if bo == nil { |
| 217 | bo = backoff.NewExponentialBackOff( |
| 218 | backoff.WithMaxElapsedTime(10*time.Second), |
| 219 | backoff.WithInitialInterval(300*time.Millisecond), |
| 220 | backoff.WithMaxInterval(10*time.Second), |
| 221 | backoff.WithMultiplier(1.5), |
| 222 | ) |
| 223 | } |
| 224 | |
| 225 | jobWithPR, err := fetchJobWithBackoff(ctx, client, repo, job.ID, bo) |
| 226 | if jobWithPR != nil { |
| 227 | return agentSessionWebURL(repo, jobWithPR), nil |
| 228 | } |
| 229 | return "", err |
| 230 | } |
| 231 | |
| 232 | // fetchJobWithBackoff polls the job resource until a PR number is present or the overall |
| 233 | // timeout elapses. It returns the updated Job on success, (nil, nil) on timeout, |
no test coverage detected