sqlite

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicateKey is returned when a unique constraint is violated.
	ErrDuplicateKey = errors.New("record already exists")

	// ErrNoRecord is returned when a record is not found.
	ErrNoRecord = errors.New("record not found")

	// ErrRepoNotExist is returned when a repository does not exist.
	ErrRepoNotExist = fmt.Errorf("repository does not exist")
)

Functions

This section is empty.

Types

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is a Git repository with metadata stored in a SQLite database.

func (*Repo) Description

func (r *Repo) Description() string

Description returns the repository's description.

It implements backend.Repository.

func (*Repo) IsHidden

func (r *Repo) IsHidden() bool

IsHidden returns whether the repository is hidden.

It implements backend.Repository.

func (*Repo) IsMirror

func (r *Repo) IsMirror() bool

IsMirror returns whether the repository is a mirror.

It implements backend.Repository.

func (*Repo) IsPrivate

func (r *Repo) IsPrivate() bool

IsPrivate returns whether the repository is private.

It implements backend.Repository.

func (*Repo) Name

func (r *Repo) Name() string

Name returns the repository's name.

It implements backend.Repository.

func (*Repo) Open

func (r *Repo) Open() (*git.Repository, error)

Open opens the repository.

It implements backend.Repository.

func (*Repo) ProjectName

func (r *Repo) ProjectName() string

ProjectName returns the repository's project name.

It implements backend.Repository.

func (*Repo) UpdatedAt

func (r *Repo) UpdatedAt() time.Time

UpdatedAt returns the repository's last update time.

type SqliteBackend

type SqliteBackend struct {
	// contains filtered or unexported fields
}

SqliteBackend is a backend that uses a SQLite database as a Soft Serve backend.

func NewSqliteBackend

func NewSqliteBackend(ctx context.Context) (*SqliteBackend, error)

NewSqliteBackend creates a new SqliteBackend.

func (*SqliteBackend) AccessLevel

func (d *SqliteBackend) AccessLevel(repo string, username string) backend.AccessLevel

AccessLevel returns the access level of a user for a repository.

It implements backend.Backend.

func (*SqliteBackend) AccessLevelByPublicKey

func (d *SqliteBackend) AccessLevelByPublicKey(repo string, pk ssh.PublicKey) backend.AccessLevel

AccessLevelByPublicKey returns the access level of a user's public key for a repository.

It implements backend.Backend.

func (*SqliteBackend) AddCollaborator

func (d *SqliteBackend) AddCollaborator(repo string, username string) error

AddCollaborator adds a collaborator to a repository.

It implements backend.Backend.

func (*SqliteBackend) AddPublicKey

func (d *SqliteBackend) AddPublicKey(username string, pk ssh.PublicKey) error

AddPublicKey adds a public key to a user.

It implements backend.Backend.

func (*SqliteBackend) AllowKeyless

func (d *SqliteBackend) AllowKeyless() bool

AllowKeyless returns whether or not keyless access is allowed.

It implements backend.Backend.

func (*SqliteBackend) AnonAccess

func (d *SqliteBackend) AnonAccess() backend.AccessLevel

AnonAccess returns the level of anonymous access.

It implements backend.Backend.

func (*SqliteBackend) Close

func (d *SqliteBackend) Close() error

Close closes the database.

func (*SqliteBackend) Collaborators

func (d *SqliteBackend) Collaborators(repo string) ([]string, error)

Collaborators returns a list of collaborators for a repository.

It implements backend.Backend.

func (*SqliteBackend) CreateRepository

func (d *SqliteBackend) CreateRepository(name string, opts backend.RepositoryOptions) (backend.Repository, error)

CreateRepository creates a new repository.

It implements backend.Backend.

func (*SqliteBackend) CreateUser

func (d *SqliteBackend) CreateUser(username string, opts backend.UserOptions) (backend.User, error)

CreateUser creates a new user.

It implements backend.Backend.

func (*SqliteBackend) DeleteRepository

func (d *SqliteBackend) DeleteRepository(name string) error

DeleteRepository deletes a repository.

It implements backend.Backend.

func (*SqliteBackend) DeleteUser

func (d *SqliteBackend) DeleteUser(username string) error

DeleteUser deletes a user.

It implements backend.Backend.

func (*SqliteBackend) Description

func (d *SqliteBackend) Description(repo string) (string, error)

Description returns the description of a repository.

It implements backend.Backend.

func (*SqliteBackend) ImportRepository

func (d *SqliteBackend) ImportRepository(name string, remote string, opts backend.RepositoryOptions) (backend.Repository, error)

ImportRepository imports a repository from remote.

func (*SqliteBackend) IsCollaborator

func (d *SqliteBackend) IsCollaborator(repo string, username string) (bool, error)

IsCollaborator returns true if the user is a collaborator of the repository.

It implements backend.Backend.

func (*SqliteBackend) IsHidden

func (d *SqliteBackend) IsHidden(repo string) (bool, error)

IsHidden returns true if the repository is hidden.

It implements backend.Backend.

func (*SqliteBackend) IsMirror

func (d *SqliteBackend) IsMirror(repo string) (bool, error)

IsMirror returns true if the repository is a mirror.

It implements backend.Backend.

func (*SqliteBackend) IsPrivate

func (d *SqliteBackend) IsPrivate(repo string) (bool, error)

IsPrivate returns true if the repository is private.

It implements backend.Backend.

func (*SqliteBackend) ListPublicKeys

func (d *SqliteBackend) ListPublicKeys(username string) ([]ssh.PublicKey, error)

ListPublicKeys lists the public keys of a user.

func (*SqliteBackend) PostReceive

func (d *SqliteBackend) PostReceive(stdout io.Writer, stderr io.Writer, repo string, args []backend.HookArg)

PostReceive is called by the git post-receive hook.

It implements Hooks.

func (*SqliteBackend) PostUpdate

func (d *SqliteBackend) PostUpdate(stdout io.Writer, stderr io.Writer, repo string, args ...string)

PostUpdate is called by the git post-update hook.

It implements Hooks.

func (*SqliteBackend) PreReceive

func (d *SqliteBackend) PreReceive(stdout io.Writer, stderr io.Writer, repo string, args []backend.HookArg)

PreReceive is called by the git pre-receive hook.

It implements Hooks.

func (*SqliteBackend) ProjectName

func (d *SqliteBackend) ProjectName(repo string) (string, error)

ProjectName returns the project name of a repository.

It implements backend.Backend.

func (*SqliteBackend) RemoveCollaborator

func (d *SqliteBackend) RemoveCollaborator(repo string, username string) error

RemoveCollaborator removes a collaborator from a repository.

It implements backend.Backend.

func (*SqliteBackend) RemovePublicKey

func (d *SqliteBackend) RemovePublicKey(username string, pk ssh.PublicKey) error

RemovePublicKey removes a public key from a user.

It implements backend.Backend.

func (*SqliteBackend) RenameRepository

func (d *SqliteBackend) RenameRepository(oldName string, newName string) error

RenameRepository renames a repository.

It implements backend.Backend.

func (*SqliteBackend) Repositories

func (d *SqliteBackend) Repositories() ([]backend.Repository, error)

Repositories returns a list of all repositories.

It implements backend.Backend.

func (*SqliteBackend) Repository

func (d *SqliteBackend) Repository(repo string) (backend.Repository, error)

Repository returns a repository by name.

It implements backend.Backend.

func (*SqliteBackend) SetAdmin

func (d *SqliteBackend) SetAdmin(username string, admin bool) error

SetAdmin sets the admin flag of a user.

It implements backend.Backend.

func (*SqliteBackend) SetAllowKeyless

func (d *SqliteBackend) SetAllowKeyless(allow bool) error

SetAllowKeyless sets whether or not keyless access is allowed.

It implements backend.Backend.

func (*SqliteBackend) SetAnonAccess

func (d *SqliteBackend) SetAnonAccess(level backend.AccessLevel) error

SetAnonAccess sets the level of anonymous access.

It implements backend.Backend.

func (*SqliteBackend) SetDescription

func (d *SqliteBackend) SetDescription(repo string, desc string) error

SetDescription sets the description of a repository.

It implements backend.Backend.

func (*SqliteBackend) SetHidden

func (d *SqliteBackend) SetHidden(repo string, hidden bool) error

SetHidden sets the hidden flag of a repository.

It implements backend.Backend.

func (*SqliteBackend) SetPrivate

func (d *SqliteBackend) SetPrivate(repo string, private bool) error

SetPrivate sets the private flag of a repository.

It implements backend.Backend.

func (*SqliteBackend) SetProjectName

func (d *SqliteBackend) SetProjectName(repo string, name string) error

SetProjectName sets the project name of a repository.

It implements backend.Backend.

func (*SqliteBackend) SetUsername

func (d *SqliteBackend) SetUsername(username string, newUsername string) error

SetUsername sets the username of a user.

It implements backend.Backend.

func (*SqliteBackend) Update

func (d *SqliteBackend) Update(stdout io.Writer, stderr io.Writer, repo string, arg backend.HookArg)

Update is called by the git update hook.

It implements Hooks.

func (*SqliteBackend) User

func (d *SqliteBackend) User(username string) (backend.User, error)

User finds a user by username.

It implements backend.Backend.

func (*SqliteBackend) UserByPublicKey

func (d *SqliteBackend) UserByPublicKey(pk ssh.PublicKey) (backend.User, error)

UserByPublicKey finds a user by public key.

It implements backend.Backend.

func (*SqliteBackend) Users

func (d *SqliteBackend) Users() ([]string, error)

Users returns all users.

It implements backend.Backend.

type User

type User struct {
	// contains filtered or unexported fields
}

User represents a user.

func (*User) IsAdmin

func (u *User) IsAdmin() bool

IsAdmin returns whether the user is an admin.

It implements backend.User.

func (*User) PublicKeys

func (u *User) PublicKeys() []ssh.PublicKey

PublicKeys returns the user's public keys.

It implements backend.User.

func (*User) Username

func (u *User) Username() string

Username returns the user's username.

It implements backend.User.

Jump to

Keyboard shortcuts

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