branches

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeFrozen = iota
	ModeExpand
	ModeShrink
)
View Source
const SecretSize = 32

Variables

View Source
var (
	ErrNotExist = errors.New("branch does not exist")
	ErrExists   = errors.New("a branch already exists by that name")
)

Functions

func Apply

func Apply(ctx context.Context, b Branch, src StoreTriple, fn func(*Snap) (*Snap, error)) error

Apply applies fn to branch, any missing data will be pulled from scratch

func CheckName

func CheckName(name string) error

func CleanupVolume

func CleanupVolume(ctx context.Context, vol Volume) error

Cleanup ensures that there are no unreachable blobs in volume.

func ForEach added in v0.0.3

func ForEach(ctx context.Context, s Space, span Span, fn func(string) error) (retErr error)

ForEach is a convenience function which uses Space.List to call fn with all the branch names contained in span.

func History

func History(ctx context.Context, b Branch, vcop *gotvc.Operator, fn func(ref gdat.Ref, snap Snap) error) error

func IsExists

func IsExists(err error) bool

func IsNotExist

func IsNotExist(err error) bool

func IsValidName

func IsValidName(name string) bool

func NewGotFS added in v0.0.4

func NewGotFS(b *Branch, opts ...gotfs.Option) *gotfs.Operator

NewGotFS creates a new gotfs.Operator suitable for writing to the branch

func NewGotVC added in v0.0.4

func NewGotVC(b *Branch, opts ...gotvc.Option) *gotvc.Operator

NewGotVC creates a new gotvc.Operator suitable for writing to the branch

func SetHead

func SetHead(ctx context.Context, b Branch, src StoreTriple, snap Snap) error

SetHead forcibly sets the head of the branch.

func SortAnnotations added in v0.0.3

func SortAnnotations(s []Annotation)

func SyncVolumes

func SyncVolumes(ctx context.Context, src, dst Volume, force bool) error

SyncVolumes syncs the contents of src to dst.

func TestSpace

func TestSpace(t *testing.T, newSpace func(t testing.TB) Space)

Types

type Annotation added in v0.0.3

type Annotation struct {
	Key   string
	Value string
}

Annotation annotates a branch

func GetAnnotation added in v0.0.3

func GetAnnotation(as []Annotation, key string) (ret []Annotation)

func (*Annotation) MarshalJSON added in v0.0.3

func (a *Annotation) MarshalJSON() ([]byte, error)

func (*Annotation) UnmarshalJSON added in v0.0.3

func (a *Annotation) UnmarshalJSON(data []byte) error

type Branch

type Branch struct {
	Volume Volume
	Metadata

	CreatedAt tai64.TAI64 `json:"created_at"`
}

Branch is a Volume plus additional metadata

func CreateIfNotExists

func CreateIfNotExists(ctx context.Context, r Space, k string, md Metadata) (*Branch, error)

type CryptoSpace

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

func (*CryptoSpace) Create

func (r *CryptoSpace) Create(ctx context.Context, name string, md Metadata) (*Branch, error)

func (*CryptoSpace) Delete

func (r *CryptoSpace) Delete(ctx context.Context, name string) error

func (*CryptoSpace) Get

func (r *CryptoSpace) Get(ctx context.Context, name string) (*Branch, error)

func (*CryptoSpace) List added in v0.0.3

func (r *CryptoSpace) List(ctx context.Context, span Span, limit int) (ret []string, _ error)

func (*CryptoSpace) Set added in v0.0.3

func (r *CryptoSpace) Set(ctx context.Context, name string, md Metadata) error

type CryptoSpaceOption added in v0.0.3

type CryptoSpaceOption = func(*CryptoSpace)

CryptoSpaceOptions configure a CryptoSpace

func WithDecryptFailureHandler added in v0.0.3

func WithDecryptFailureHandler(fn func(string, error)) CryptoSpaceOption

WithDecryptFailureHandler sets fn to be called by the space when there is a decryption failure.

type Layer

type Layer struct {
	Prefix string
	Target Space
}

type MemSpace

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

func (*MemSpace) Create

func (r *MemSpace) Create(ctx context.Context, name string, md Metadata) (*Branch, error)

func (*MemSpace) Delete

func (r *MemSpace) Delete(ctx context.Context, name string) error

func (*MemSpace) Get

func (r *MemSpace) Get(ctx context.Context, name string) (*Branch, error)

func (*MemSpace) List added in v0.0.3

func (r *MemSpace) List(ctx context.Context, span Span, limit int) (ret []string, _ error)

func (*MemSpace) Set added in v0.0.3

func (r *MemSpace) Set(ctx context.Context, name string, md Metadata) error

type Metadata added in v0.0.3

type Metadata struct {
	Mode Mode   `json:"mode"`
	Salt []byte `json:"salt"`

	Annotations []Annotation `json:"annotations"`
}

Metadata is non-volume, user-modifiable information associated with a branch.

func NewMetadata added in v0.0.3

func NewMetadata(public bool) Metadata

func (Metadata) Clone added in v0.0.3

func (md Metadata) Clone() Metadata

Clone returns a deep copy of md

type Mode added in v0.0.3

type Mode uint8

func (Mode) MarshalText added in v0.0.3

func (m Mode) MarshalText() ([]byte, error)

func (Mode) String added in v0.0.3

func (m Mode) String() string

func (*Mode) UnmarshalText added in v0.0.3

func (m *Mode) UnmarshalText(data []byte) error

type PrefixSpace added in v0.0.3

type PrefixSpace struct {
	Prefix string
	Target Space
}

PrefixSpace is a Space mapped into a prefix under the Target

func NewPrefixSpace added in v0.0.3

func NewPrefixSpace(inner Space, prefix string) PrefixSpace

func (PrefixSpace) Create added in v0.0.3

func (s PrefixSpace) Create(ctx context.Context, k string, md Metadata) (*Branch, error)

func (PrefixSpace) Delete added in v0.0.3

func (s PrefixSpace) Delete(ctx context.Context, k string) error

func (PrefixSpace) Get added in v0.0.3

func (s PrefixSpace) Get(ctx context.Context, k string) (*Branch, error)

func (PrefixSpace) List added in v0.0.3

func (s PrefixSpace) List(ctx context.Context, span Span, limit int) ([]string, error)

func (PrefixSpace) Set added in v0.0.3

func (s PrefixSpace) Set(ctx context.Context, k string, md Metadata) error

type Snap

type Snap = gotvc.Snap

func GetHead

func GetHead(ctx context.Context, b Branch) (*Snap, error)

GetHead returns the branch head

type Space

type Space interface {
	Create(ctx context.Context, name string, md Metadata) (*Branch, error)
	Get(ctx context.Context, name string) (*Branch, error)
	Set(ctx context.Context, name string, md Metadata) error
	Delete(ctx context.Context, name string) error
	List(ctx context.Context, span Span, limit int) ([]string, error)
}

A Space holds named branches.

func NewCryptoSpace

func NewCryptoSpace(inner Space, secret *[32]byte, opts ...CryptoSpaceOption) Space

func NewMem

func NewMem(newStore func() cadata.Store, newCell func() cells.Cell) Space

func NewMultiSpace

func NewMultiSpace(layers []Layer) (Space, error)

type Span added in v0.0.3

type Span struct {
	Begin string
	End   string
}

func TotalSpan added in v0.0.3

func TotalSpan() Span

func (Span) Contains added in v0.0.3

func (s Span) Contains(x string) bool

type StoreTriple

type StoreTriple struct {
	VC, FS, Raw cadata.Store
}

StoreTriple is an instance of the 3 stores needed to store a Got Snapshot

type Volume

type Volume struct {
	RawStore, FSStore, VCStore cadata.Store
	Cell                       cells.Cell
}

Volume is a Cell and a set of stores

func (Volume) StoreTriple

func (v Volume) StoreTriple() StoreTriple

Jump to

Keyboard shortcuts

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