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

Function checkPermission

internal/attachments/client.go:94–105  ·  view source on GitHub ↗

checkPermission rejects a permission that cannot upload. It is an allowlist, so an unlisted value is rejected rather than sent.

(viewerPermission string)

Source from the content-addressed store, hash-verified

92// checkPermission rejects a permission that cannot upload. It is an allowlist,
93// so an unlisted value is rejected rather than sent.
94func checkPermission(viewerPermission string) error {
95 // A caller that never requested the field hands over an empty string. That
96 // is a different fault from a permission that is too low.
97 if viewerPermission == "" {
98 return errors.New("could not determine your permission on the repository to attach files")
99 }
100
101 if slices.Contains(uploadPermissions, viewerPermission) {
102 return nil
103 }
104 return errors.New("attaching files requires write access to the repository")
105}
106
107// upload sends the file's bytes and returns the asset URL to reference
108// from the markdown.

Callers 1

NewUploaderFunction · 0.85

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected