store.go

 1package store
 2
 3import (
 4	"context"
 5
 6	"github.com/go-git/go-billy/v5"
 7)
 8
 9// RepositoryOptions are options for creating a new repository.
10type RepositoryOptions struct {
11	Private     bool
12	Description string
13	ProjectName string
14	Mirror      bool
15	Hidden      bool
16}
17
18// Store is an interface for managing repositories and repository metadata.
19type Store interface {
20	// Filesystem returns the underlying git filesystem.
21	Filesystem() billy.Filesystem
22	// Repository finds the given repository.
23	Repository(ctx context.Context, repo string) (Repository, error)
24	// CountRepositories returns the number of repositories.
25	CountRepositories(ctx context.Context) (uint64, error)
26	// Repositories returns a list of all repositories.
27	Repositories(ctx context.Context, page int, perPage int) ([]Repository, error)
28	// CreateRepository creates a new repository.
29	CreateRepository(ctx context.Context, name string, opts RepositoryOptions) (Repository, error)
30	// ImportRepository creates a new repository from a Git repository.
31	ImportRepository(ctx context.Context, name string, remote string, opts RepositoryOptions) (Repository, error)
32	// DeleteRepository deletes a repository.
33	DeleteRepository(ctx context.Context, name string) error
34	// RenameRepository renames a repository.
35	RenameRepository(ctx context.Context, oldName, newName string) error
36	// ProjectName returns the repository's project name.
37	ProjectName(ctx context.Context, repo string) (string, error)
38	// SetProjectName sets the repository's project name.
39	SetProjectName(ctx context.Context, repo, name string) error
40	// Description returns the repository's description.
41	Description(ctx context.Context, repo string) (string, error)
42	// SetDescription sets the repository's description.
43	SetDescription(ctx context.Context, repo, desc string) error
44	// IsPrivate returns whether the repository is private.
45	IsPrivate(ctx context.Context, repo string) (bool, error)
46	// SetPrivate sets whether the repository is private.
47	SetPrivate(ctx context.Context, repo string, private bool) error
48	// IsMirror returns whether the repository is a mirror.
49	IsMirror(ctx context.Context, repo string) (bool, error)
50	// IsHidden returns whether the repository is hidden.
51	IsHidden(ctx context.Context, repo string) (bool, error)
52	// SetHidden sets whether the repository is hidden.
53	SetHidden(ctx context.Context, repo string, hidden bool) error
54	// Touch updates the repository's last activity time.
55	Touch(ctx context.Context, repo string) error
56}