package view import ( "errors" "fmt" "io" "net/http" "github.com/cli/cli/api" "github.com/cli/cli/internal/ghinstance" "github.com/cli/cli/internal/ghrepo" "github.com/cli/cli/pkg/cmd/run/shared" ) func jobLog(httpClient *http.Client, repo ghrepo.Interface, jobID string) (io.ReadCloser, error) { url := fmt.Sprintf("%srepos/%s/actions/jobs/%s/logs", ghinstance.RESTPrefix(repo.RepoHost()), ghrepo.FullName(repo), jobID) req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } resp, err := httpClient.Do(req) if err != nil { return nil, err } if resp.StatusCode == 404 { return nil, errors.New("job not found") } else if resp.StatusCode != 200 { return nil, api.HandleHTTPError(resp) } return resp.Body, nil } func getJob(client *api.Client, repo ghrepo.Interface, jobID string) (*shared.Job, error) { path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID) var result shared.Job err := client.REST(repo.RepoHost(), "GET", path, nil, &result) if err != nil { return nil, err } return &result, nil }