proto

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized is returned when the user is not authorized to perform action.
	ErrUnauthorized = errors.New("unauthorized")
	// ErrFileNotFound is returned when the file is not found.
	ErrFileNotFound = errors.New("file not found")
	// ErrRepoNotFound is returned when a repository is not found.
	ErrRepoNotFound = errors.New("repository not found")
	// ErrRepoExist is returned when a repository already exists.
	ErrRepoExist = errors.New("repository already exists")
	// ErrUserNotFound is returned when a user is not found.
	ErrUserNotFound = errors.New("user not found")
	// ErrTokenNotFound is returned when a token is not found.
	ErrTokenNotFound = errors.New("token not found")
	// ErrTokenExpired is returned when a token is expired.
	ErrTokenExpired = errors.New("token expired")
	// ErrCollaboratorNotFound is returned when a collaborator is not found.
	ErrCollaboratorNotFound = errors.New("collaborator not found")
)
View Source
var ContextKeyRepository = &struct{ string }{"repository"}

ContextKeyRepository is the context key for the repository.

View Source
var ContextKeyUser = &struct{ string }{"user"}

ContextKeyUser is the context key for the user.

Functions

func RepositoryDefaultBranch

func RepositoryDefaultBranch(repo Repository) (string, error)

RepositoryDefaultBranch returns the default branch of a repository.

func WithRepositoryContext

func WithRepositoryContext(ctx context.Context, r Repository) context.Context

WithRepositoryContext returns a new context with the repository.

func WithUserContext

func WithUserContext(ctx context.Context, u User) context.Context

WithUserContext returns a new context with the user.

Types

type AccessToken

type AccessToken struct {
	ID        int64
	Name      string
	UserID    int64
	TokenHash string
	ExpiresAt time.Time
	CreatedAt time.Time
}

AccessToken represents an access token.

type Repository

type Repository interface {
	// ID returns the repository's ID.
	ID() int64
	// Name returns the repository's name.
	Name() string
	// ProjectName returns the repository's project name.
	ProjectName() string
	// Description returns the repository's description.
	Description() string
	// IsPrivate returns whether the repository is private.
	IsPrivate() bool
	// IsMirror returns whether the repository is a mirror.
	IsMirror() bool
	// IsHidden returns whether the repository is hidden.
	IsHidden() bool
	// UserID returns the ID of the user who owns the repository.
	// It returns 0 if the repository is not owned by a user.
	UserID() int64
	// CreatedAt returns the time the repository was created.
	CreatedAt() time.Time
	// UpdatedAt returns the time the repository was last updated.
	// If the repository has never been updated, it returns the time it was created.
	UpdatedAt() time.Time
	// Open returns the underlying git.Repository.
	Open() (*git.Repository, error)
}

Repository is a Git repository interface.

func RepositoryFromContext

func RepositoryFromContext(ctx context.Context) Repository

RepositoryFromContext returns the repository from the context.

type RepositoryOptions

type RepositoryOptions struct {
	Private     bool
	Description string
	ProjectName string
	Mirror      bool
	Hidden      bool
	LFS         bool
	LFSEndpoint string
}

RepositoryOptions are options for creating a new repository.

type User

type User interface {
	// ID returns the user's ID.
	ID() int64
	// Username returns the user's username.
	Username() string
	// IsAdmin returns whether the user is an admin.
	IsAdmin() bool
	// PublicKeys returns the user's public keys.
	PublicKeys() []ssh.PublicKey
	// Password returns the user's password hash.
	Password() string
}

User is an interface representing a user.

func UserFromContext

func UserFromContext(ctx context.Context) User

UserFromContext returns the user from the context.

type UserOptions

type UserOptions struct {
	// Admin is whether the user is an admin.
	Admin bool
	// PublicKeys are the user's public keys.
	PublicKeys []ssh.PublicKey
}

UserOptions are options for creating a user.

Jump to

Keyboard shortcuts

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