(httpClient *http.Client, hostname string, logPath safeurl.SafeURL)
| 485 | } |
| 486 | |
| 487 | func getLog(httpClient *http.Client, hostname string, logPath safeurl.SafeURL) (io.ReadCloser, error) { |
| 488 | // The response body is the log archive, which is handed to the caller rather than decoded. |
| 489 | // TODO(api-client-rollout) |
| 490 | // This line of code is part of a mechanical roll out of the api client. |
| 491 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 492 | resp, err := api.NewClientFromHTTP(httpClient).Request(hostname, http.MethodGet, logPath.String(), nil) |
| 493 | if err != nil { |
| 494 | if httpErr, ok := errors.AsType[api.HTTPError](err); ok && httpErr.StatusCode == http.StatusNotFound { |
| 495 | return nil, errors.New("log not found") |
| 496 | } |
| 497 | return nil, err |
| 498 | } |
| 499 | |
| 500 | if resp.StatusCode != http.StatusOK { |
| 501 | defer resp.Body.Close() |
| 502 | return nil, api.UnexpectedStatusError(resp) |
| 503 | } |
| 504 | |
| 505 | return resp.Body, nil |
| 506 | } |
| 507 | |
| 508 | func getRunLog(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64) (*zip.ReadCloser, error) { |
| 509 | cacheKey := fmt.Sprintf("%d-%d", run.ID, run.StartedTime().Unix()) |
no test coverage detected