access

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL