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

Method GetLog

pkg/cmd/run/view/logs.go:42–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42func (f *apiLogFetcher) GetLog() (io.ReadCloser, error) {
43 logURL, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(f.repo.RepoHost()), "repos", f.repo.RepoOwner(), f.repo.RepoName(), "actions", "jobs", strconv.FormatInt(f.jobID, 10), "logs")
44 if err != nil {
45 return nil, err
46 }
47
48 // TODO(api-client-rollout)
49 // This has been deferred from moving to api.Client due to returning the job log response body as an io.ReadCloser instead of decoding JSON.
50 req, err := http.NewRequest("GET", logURL.String(), nil)
51 if err != nil {
52 return nil, err
53 }
54
55 resp, err := f.httpClient.Do(req)
56 if err != nil {
57 return nil, err
58 }
59
60 if resp.StatusCode == 404 {
61 return nil, fmt.Errorf("log not found: %v", f.jobID)
62 } else if resp.StatusCode != 200 {
63 return nil, api.HandleHTTPError(resp)
64 }
65
66 return resp.Body, nil
67}
68
69// logSegment represents a segment of a log trail, which can be either an entire
70// job log or an individual step log.

Callers 1

TestApiLogFetcherFunction · 0.95

Calls 9

JoinPathWithHostPrefixFunction · 0.92
RESTPrefixFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
StringMethod · 0.65
DoMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestApiLogFetcherFunction · 0.76