Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ContextKey = &struct{ string }{"access"}
ContextKey is the context key for the access level.
View Source
var ErrInvalidAccessLevel = errors.New("invalid access level")
ErrInvalidAccessLevel is returned when an invalid access level is provided.
Functions ¶
func WithContext ¶
func WithContext(ctx context.Context, ac AccessLevel) context.Context
WithContext returns a new context with the access level.
Types ¶
type AccessLevel ¶
type AccessLevel int // nolint: revive
AccessLevel is the level of access allowed to a repo.
const ( // NoAccess does not allow access to the repo. NoAccess AccessLevel = iota // ReadOnlyAccess allows read-only access to the repo. ReadOnlyAccess // ReadWriteAccess allows read and write access to the repo. ReadWriteAccess // AdminAccess allows read, write, and admin access to the repo. AdminAccess )
func FromContext ¶
func FromContext(ctx context.Context) AccessLevel
FromContext returns the access level from the context.
func ParseAccessLevel ¶
func ParseAccessLevel(s string) AccessLevel
ParseAccessLevel parses an access level string.
func (AccessLevel) MarshalText ¶
func (a AccessLevel) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler.
func (AccessLevel) String ¶
func (a AccessLevel) String() string
String returns the string representation of the access level.
func (*AccessLevel) UnmarshalText ¶
func (a *AccessLevel) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
Click to show internal directories.
Click to hide internal directories.