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

Function ListArtifacts

pkg/cmd/run/shared/artifacts.go:23–60  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, runID string)

Source from the content-addressed store, hash-verified

21}
22
23func ListArtifacts(httpClient *http.Client, repo ghrepo.Interface, runID string) ([]Artifact, error) {
24 var results []Artifact
25
26 perPage := 100
27 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "artifacts")
28 if err != nil {
29 return nil, err
30 }
31 if runID != "" {
32 u, err = safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", runID, "artifacts")
33 if err != nil {
34 return nil, err
35 }
36 }
37 u.SetQuery("per_page", strconv.Itoa(perPage))
38 var pageURL safeurl.SafeURL = u
39
40 // TODO(api-client-rollout)
41 // This line of code is part of a mechanical roll out of the api client.
42 // As a follow up, consider whether the api client can be injected to this call site, rather than constructed
43 client := api.NewClientFromHTTP(httpClient)
44
45 for {
46 var payload artifactsPayload
47 nextURL, err := client.RESTWithNext(repo.RepoHost(), http.MethodGet, pageURL.String(), nil, &payload)
48 if err != nil {
49 return nil, err
50 }
51 results = append(results, payload.Artifacts...)
52
53 if nextURL == "" {
54 break
55 }
56 pageURL = safeurl.NewImmutableSafeURL(nextURL)
57 }
58
59 return results, nil
60}

Callers 4

runViewFunction · 0.92
ListMethod · 0.92

Calls 9

StringMethod · 0.95
JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
NewImmutableSafeURLFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTWithNextMethod · 0.65
RepoHostMethod · 0.65