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

Function getLog

pkg/cmd/run/view/view.go:488–507  ·  view source on GitHub ↗
(httpClient *http.Client, hostname string, logPath safeurl.SafeURL)

Source from the content-addressed store, hash-verified

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

Callers 1

getRunLogFunction · 0.85

Calls 5

NewClientFromHTTPFunction · 0.92
UnexpectedStatusErrorFunction · 0.92
RequestMethod · 0.80
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected