(httpClient *http.Client, hostname string, logPath safeurl.SafeURL)
| 469 | } |
| 470 | |
| 471 | func getLog(httpClient *http.Client, hostname string, logPath safeurl.SafeURL) (io.ReadCloser, error) { |
| 472 | // The response body is the log archive, which is handed to the caller rather than decoded. |
| 473 | // TODO(api-client-rollout) |
| 474 | // This line of code is part of a mechanical roll out of the api client. |
| 475 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 476 | resp, err := api.NewClientFromHTTP(httpClient).Request(hostname, http.MethodGet, logPath.String(), nil) |
| 477 | if err != nil { |
| 478 | if httpErr, ok := errors.AsType[api.HTTPError](err); ok && httpErr.StatusCode == http.StatusNotFound { |
| 479 | return nil, errors.New("log not found") |
| 480 | } |
| 481 | return nil, err |
| 482 | } |
| 483 | |
| 484 | if resp.StatusCode != http.StatusOK { |
| 485 | defer resp.Body.Close() |
| 486 | return nil, api.UnexpectedStatusError(resp) |
| 487 | } |
| 488 | |
| 489 | return resp.Body, nil |
| 490 | } |
| 491 | |
| 492 | func getRunLog(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64) (*zip.ReadCloser, error) { |
| 493 | cacheKey := fmt.Sprintf("%d-%d", run.ID, run.StartedTime().Unix()) |
no test coverage detected