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

Function NewUploader

pkg/cmd/issue/artifact/shared/shared.go:262–272  ·  view source on GitHub ↗

NewUploader returns the uploader for a command's --attach files, which upload against the issue's repository with the token for its host. It refuses a pull request like CheckIssue, from the one lookup that also returns the repository ID and permission an upload needs, so a caller makes no other look

(c client.ArtifactClient, repo ghrepo.Interface, issueNumber int, httpClient func() (*http.Client, error))

Source from the content-addressed store, hash-verified

260// returns the repository ID and permission an upload needs, so a caller makes
261// no other lookup.
262func NewUploader(c client.ArtifactClient, repo ghrepo.Interface, issueNumber int, httpClient func() (*http.Client, error)) (*attachments.Uploader, error) {
263 target, err := CheckUploadTarget(c, repo, issueNumber)
264 if err != nil {
265 return nil, err
266 }
267 hc, err := httpClient()
268 if err != nil {
269 return nil, err
270 }
271 return attachments.NewUploader(hc, repo.RepoHost(), target.RepositoryID, target.ViewerPermission)
272}
273
274func pullRequestError(repo ghrepo.Interface, number int) error {
275 return fmt.Errorf("%s#%d is a pull request; artifacts are only supported on issues", ghrepo.FullName(repo), number)

Callers 3

createRunFunction · 0.92
editRunFunction · 0.92
TestNewUploaderFunction · 0.70

Calls 4

NewUploaderFunction · 0.92
CheckUploadTargetFunction · 0.85
httpClientInterface · 0.85
RepoHostMethod · 0.65

Tested by 1

TestNewUploaderFunction · 0.56