repository

package
v0.0.0-...-c0337eb Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrExists   = errors.New("exists")
)

Functions

This section is empty.

Types

type FilesystemRepoStore

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

FilesystemRepoStore is a file based repo datastore

func NewFilesystemRepoStore

func NewFilesystemRepoStore(dir string) *FilesystemRepoStore

NewFilesystemRepoStore instantiates a new repo store

func (*FilesystemRepoStore) CreateRepo

func (mrs *FilesystemRepoStore) CreateRepo(repo *Repository) error

CreateRepo with the given repo data

func (*FilesystemRepoStore) GetRepo

func (mrs *FilesystemRepoStore) GetRepo(id string) (*Repository, error)

GetRepo with the given id

func (*FilesystemRepoStore) RemoveRepo

func (mrs *FilesystemRepoStore) RemoveRepo(id string) error

RemoveRepo with the given id

func (*FilesystemRepoStore) UpdateRepo

func (mrs *FilesystemRepoStore) UpdateRepo(repo *Repository) error

UpdateRepo with the given data

type GitRepoManager

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

func NewGitRepoManager

func NewGitRepoManager(dir string) *GitRepoManager

func (*GitRepoManager) CreateRepo

func (m *GitRepoManager) CreateRepo(id string) error

func (*GitRepoManager) GetRepo

func (m *GitRepoManager) GetRepo(id string) (*git.Repository, error)

func (*GitRepoManager) RemoveRepo

func (m *GitRepoManager) RemoveRepo(id string) error

type Manager

type Manager struct {
	RepositoryStore
	// contains filtered or unexported fields
}

Manager wraps an underlying repo store with a git repo manager to initialize repos

func NewManager

func NewManager(s RepositoryStore, mgr *GitRepoManager) *Manager

func (*Manager) CreateRepo

func (s *Manager) CreateRepo(repo *Repository) error

type MemRepoStore

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

MemRepoStore is a memory based repo datastore

func NewMemRepoStore

func NewMemRepoStore() *MemRepoStore

NewMemRepoStore instantiates a new repo store

func (*MemRepoStore) CreateRepo

func (mrs *MemRepoStore) CreateRepo(repo *Repository) error

CreateRepo with the given repo data

func (*MemRepoStore) GetRepo

func (mrs *MemRepoStore) GetRepo(id string) (*Repository, error)

GetRepo with the given id

func (*MemRepoStore) RemoveRepo

func (mrs *MemRepoStore) RemoveRepo(id string) error

RemoveRepo with the given id

func (*MemRepoStore) UpdateRepo

func (mrs *MemRepoStore) UpdateRepo(repo *Repository) error

UpdateRepo with the given data

type Repository

type Repository struct {
	ID   string                `json:"id"`
	Refs *RepositoryReferences `json:"refs"`
}

Repository represents a single repo.

func NewRepository

func NewRepository(id string) *Repository

NewRepository instantiates an empty repo.

func (*Repository) String

func (repo *Repository) String() string

type RepositoryHead

type RepositoryHead struct {
	Ref  string        `json:"ref"`
	Hash plumbing.Hash `json:"hash"`
}

RepositoryHead contains the HEAD ref and hash information

type RepositoryReferences

type RepositoryReferences struct {

	// TODO: Although head is exposed it should be be used directly when setting its
	// value.  It is only here to until a msgpack marshaller is implemented.
	Head  RepositoryHead
	Heads map[string]plumbing.Hash
	Tags  map[string]plumbing.Hash
	// contains filtered or unexported fields
}

RepositoryReferences contains repo refs and head information.

func NewRepositoryReferences

func NewRepositoryReferences() *RepositoryReferences

NewRepositoryReferences instantiates a new RepositoryReferences structure with the defaults.

func (*RepositoryReferences) MarshalJSON

func (refs *RepositoryReferences) MarshalJSON() ([]byte, error)

MarshalJSON is a custom json marshaller for the repository specifically to handle hashes.

func (*RepositoryReferences) SetHead

func (refs *RepositoryReferences) SetHead(ref string) (plumbing.Hash, error)

SetHead given the ref. Returns an error if the ref is not found or invalid.

func (*RepositoryReferences) UpdateRef

func (refs *RepositoryReferences) UpdateRef(ref string, prev, curr plumbing.Hash) error

UpdateRef updates a repo reference given the previous hash of the ref.

type RepositoryStore

type RepositoryStore interface {
	GetRepo(string) (*Repository, error)
	CreateRepo(*Repository) error
	UpdateRepo(*Repository) error
	RemoveRepo(string) error
}

RepositoryStore is the repository storage interface that should be implemented.

Jump to

Keyboard shortcuts

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