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

Function checkPermission

internal/attachments/client.go:96–107  ·  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

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

Callers 1

NewUploaderFunction · 0.85

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected