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

Function checkPermission

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

71// checkPermission rejects a permission that cannot upload. It is an allowlist,
72// so an unlisted value is rejected rather than sent.
73func checkPermission(viewerPermission string) error {
74 // GraphQL has no viewerPermission for a GitHub App installation, so an
75 // empty one is left to the endpoint rather than refused.
76 if viewerPermission == "" {
77 return nil
78 }
79
80 if slices.Contains(uploadPermissions, viewerPermission) {
81 return nil
82 }
83 return errors.New("attaching files requires write access to the repository")
84}
85
86// upload sends the file's bytes and returns the asset URL to reference
87// from the markdown.

Callers 1

NewUploaderFunction · 0.85

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected