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

Function NewUploader

internal/attachments/client.go:38–55  ·  view source on GitHub ↗

NewUploader prepares uploads against targetRepository, the numeric REST id of the repository the assets are uploaded against, and viewerPermission, the GraphQL viewerPermission field on that same repository. It refuses what gh can tell will not upload. The credential is left to the endpoint, which a

(httpClient *http.Client, host string, targetRepository int64, viewerPermission string)

Source from the content-addressed store, hash-verified

36// upload work, so any other order would name a fault the user cannot fix. The
37// other checks are free to move.
38func NewUploader(httpClient *http.Client, host string, targetRepository int64, viewerPermission string) (*Uploader, error) {
39 if err := checkHost(host); err != nil {
40 return nil, err
41 }
42
43 if targetRepository <= 0 {
44 return nil, errors.New("could not determine which repository to attach files to")
45 }
46
47 if err := checkPermission(viewerPermission); err != nil {
48 return nil, err
49 }
50
51 // TODO(api-client-rollout)
52 // This line of code is part of a mechanical roll out of the api client.
53 // As a follow up, consider whether the api client can be injected to this call site, rather than constructed
54 return &Uploader{client: api.NewClientFromHTTP(httpClient), host: host, targetRepository: targetRepository}, nil
55}
56
57// checkHost rejects a host that cannot serve the upload endpoint. IsEnterprise
58// is false for ghe.com tenants, so data residency keeps working.

Callers 9

createRunFunction · 0.92
NewUploaderFunction · 0.92
editRunFunction · 0.92
CommentableRunFunction · 0.92
createRunFunction · 0.92
editRunFunction · 0.92
newTestUploaderFunction · 0.70
TestUploadAuthenticationFunction · 0.70
TestNewUploaderFunction · 0.70

Calls 3

NewClientFromHTTPFunction · 0.92
checkHostFunction · 0.85
checkPermissionFunction · 0.85

Tested by 3

newTestUploaderFunction · 0.56
TestUploadAuthenticationFunction · 0.56
TestNewUploaderFunction · 0.56