gotrepo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultIden = "default"

Variables

This section is empty.

Functions

func EditConfig

func EditConfig(repo *os.Root, fn func(x Config) Config) error

EditConfig applies fn to the config of the repo at repoPath

func Init

func Init(root *os.Root, config Config) error

Init initializes a new repo at the given path. If bc is nil, a local blobcache will be created within the .got directory.

func RepoVolumeSpec

func RepoVolumeSpec(useSchema bool) blobcache.VolumeSpec

RepoVolumeSpec returns a Blobcache Volume spec which can be used to create a Volume suitable for a Repo.

Types

type BlobcacheSpec

type BlobcacheSpec struct {
	// InProcess uses an in-process Blobcache service.
	// The state will be stored in the .got/blobcache directory.
	// This is the default.
	// The state can get quite large for large datasets, so it is recommended to use the system's Blobcache.
	InProcess *InProcessBlobcache `json:"in_process,omitempty"`
	// Client uses the Client Blobcache service, as configured through BLOBCACHE_API
	Client *ExternalBlobcache `json:"client,omitempty"`
}

BlobcacheSpec describes how to access a Blobcache Service.

type Config

type Config struct {
	// Blobcache configures access to a Blobcache service.
	// Got stores most of it's data in Blobcache.
	Blobcache BlobcacheSpec `json:"blobcache"`
	// RepoVolume is the OID of the volume that stores the repo's data.
	// This is different than the volume for the namespace.
	// This volume will have a link to the namespace volume.
	RepoVolume blobcache.OID `json:"repo_volume"`

	// Identities are named identities, which refer to files in the .got/iden directory
	Identities map[string]inet256.ID `json:"identities"`
	// Spaces contain named mutable references to Snapshots
	// They are most similar to git remotes.
	Spaces map[string]SpaceSpec `json:"spaces"`
	Fetch  []FetchConfig        `json:"fetch"`
	Dist   []DistConfig         `json:"dist"`
}

Config contains runtime parameters for a Repo

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig(repo *os.Root) (*Config, error)

func (*Config) AddFetch

func (c *Config) AddFetch(fc FetchConfig) *Config

func (*Config) PutSpace

func (c *Config) PutSpace(name string, spec SpaceSpec) *Config

func (*Config) SetBlobcache

func (c *Config) SetBlobcache(spec BlobcacheSpec) *Config

func (*Config) Validate

func (c *Config) Validate() error

type DistConfig

type DistConfig struct {
	// Filter is a regexp for which marks to fetch from the source space.
	// In the case of distribution, the is always the local space.
	Filter *regexp.Regexp `json:"filter"`
	// CutPrefix is the prefix to remove from the name
	// The zero value does not change the name at all.
	CutPrefix string `json:"cut_prefix"`
	// AddPrefix is the prefix to add to the name
	// before inserting into the local space.
	// The zero value does not change the name at all.
	AddPrefix string `json:"add_prefix"`
	// To is the name of the space to write to.
	To string `json:"to"`
	// Delete is the regexp for which marks to delete from the destination space.
	// Only names starting with AddPrefix in the destination space are considered.
	// The regexp should match the entire name including the prefix.
	Delete *regexp.Regexp `json:"delete"`
}

DistConfig configures a distribution task.

type Env

type Env struct {
	Background context.Context
	Dir        *os.Root
	Blobcache  blobcache.Service

	// CloseAll causes Repo.Close to also close these resources.
	CloseAll bool
}

Env is the environment that the Repo needs to function.

type ExternalBlobcache

type ExternalBlobcache struct {
	URL       string `json:"url"`
	UseSchema bool   `json:"schema"`
}

type FQM

type FQM struct {
	Space string `json:"space"`
	Name  string `json:"name"`
}

FQM represents a fully qualified Mark name.

func ParseFQName

func ParseFQName(s string) FQM

type FetchConfig

type FetchConfig struct {
	// From is the name of the space to pull from.
	// The destination space is always assumed to be the local space.
	From string `json:"from"`
	// Filter is a regexp for which marks to fetch from the source space.
	Filter *regexp.Regexp `json:"filter"`
	// CutPrefix is the prefix to remove from the name
	// The zero value does not change the name at all.
	CutPrefix string `json:"cut_prefix"`
	// AddPrefix is the prefix to add to the name
	// before inserting into the local space.
	// The zero value does not change the name at all.
	AddPrefix string `json:"add_prefix"`
	// Delete is the regexp for which marks to delete from the destination space.
	// Only names starting with AddPrefix in the destination space are considered.
	// The regexp should match the entire name including the prefix.
	Delete *regexp.Regexp `json:"delete"`
}

FetchConfig configures a fetch task.

type InProcessBlobcache

type InProcessBlobcache struct {
	ActAs    string       `json:"act_as"`
	CanLook  []inet256.ID `json:"can_look"`
	CanTouch []inet256.ID `json:"can_touch"`
}

type MarkInfo

type MarkInfo = marks.Info

type Ref

type Ref = gotkv.Ref

type Repo

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

Repo manages configuration including the connection to Blobcache The Repo can optionally host it's own Blobcache Node. Repos also manage a namespace and multiple stages. Working Copies can be created to manipulate the contents of the stages.

func New

func New(env Env, cfg Config) *Repo

New creates a new repo once the environment is setup.

func NewTestRepo

func NewTestRepo(t testing.TB) *Repo

func Open

func Open(root *os.Root) (_ *Repo, retErr error)

func (*Repo) BeginStagingTx

func (r *Repo) BeginStagingTx(ctx context.Context, wcid WorkingCopyID, modify bool) (volumes.Tx, error)

BeginStagingTx begins a new transaction for the staging area for the given WorkingCopy It is up to the caller to commit or abort the transaction.

func (*Repo) BlobcachePeer

func (r *Repo) BlobcachePeer() blobcache.PeerID

BlobcachePeer returns the PeerID used by the local Blobcache. This depends on the ActAs parameter in the Blobcache config. If the Blobcache is not local, then the zero value is returned

func (*Repo) Cat

func (r *Repo) Cat(ctx context.Context, mark FQM, p string, w io.Writer) error

func (*Repo) CheckAll

func (r *Repo) CheckAll(ctx context.Context) error

CheckAll runs integrity checks on all marks in the local Space.

func (*Repo) Cleanup

func (r *Repo) Cleanup(ctx context.Context) error

func (*Repo) CleanupMark

func (r *Repo) CleanupMark(ctx context.Context, mark FQM) error

func (*Repo) CloneMark

func (r *Repo) CloneMark(ctx context.Context, base, next FQM) error

CloneMark creates a new branch called next and sets its head to match base's

func (*Repo) Close

func (r *Repo) Close() (retErr error)

func (*Repo) Config

func (r *Repo) Config() Config

func (*Repo) Configure

func (r *Repo) Configure(fn func(x Config) Config) error

func (*Repo) ConfigureMark

func (r *Repo) ConfigureMark(ctx context.Context, fqname FQM, md marks.Metadata) error

ConfigureMark adjusts metadata

func (*Repo) CreateIdentity

func (r *Repo) CreateIdentity(ctx context.Context, name string) (*inet256.ID, error)

Create

func (*Repo) CreateMark

func (r *Repo) CreateMark(ctx context.Context, fqname FQM, mcfg marks.DSConfig, anns []marks.Annotation) (*MarkInfo, error)

CreateBranch creates a new mark in the repo's local space.

func (*Repo) DebugFS

func (r *Repo) DebugFS(ctx context.Context, mark FQM, w io.Writer) error

func (*Repo) DebugKV

func (r *Repo) DebugKV(ctx context.Context, mark FQM, w io.Writer) error

func (*Repo) DeleteMark

func (r *Repo) DeleteMark(ctx context.Context, fqname FQM) error

DeleteBranch deletes a mark The target of the mark may be garbage collected if nothing else references it.

func (*Repo) Dir

func (r *Repo) Dir() string

Dir is the path given when the Repo was opened

func (*Repo) Distribute

func (r *Repo) Distribute(ctx context.Context) error

Distribute is the opposite of Fetch.

func (*Repo) Endpoint

func (r *Repo) Endpoint() blobcache.Endpoint

func (*Repo) Fetch

func (r *Repo) Fetch(ctx context.Context) error

func (*Repo) ForEachMark

func (r *Repo) ForEachMark(ctx context.Context, spaceName string, fn func(string) error) error

ForEachBranch calls fn once for each branch, or until an error is returned from fn

func (*Repo) GCStage

func (r *Repo) GCStage(ctx context.Context, wcid WorkingCopyID) (volumes.Tx, error)

GCStage begins a new GC transaction for the staging area.

func (*Repo) GetIdentity

func (r *Repo) GetIdentity(ctx context.Context, name string) (*gotorg.IdentityUnit, error)

func (*Repo) GetMark

func (r *Repo) GetMark(ctx context.Context, fqname FQM) (*marks.Mark, error)

GetBranch returns a specific branch, or an error if it does not exist

func (*Repo) GetSpace

func (r *Repo) GetSpace(ctx context.Context, name string) (marks.Space, error)

GetSpace looks for a space with a matching name in the configuration if it finds a match, then the spec is used to construct a space and it is returned. If name is empty, then GetSpace returns the repos default namespace.

func (*Repo) History

func (r *Repo) History(ctx context.Context, mark FQM, fn func(ref Ref, s Snap) error) error

func (*Repo) Identities

func (r *Repo) Identities(ctx context.Context) (map[string]gotorg.IdentityUnit, error)

func (*Repo) InspectMark

func (r *Repo) InspectMark(ctx context.Context, fqname FQM) (*marks.Info, error)

func (*Repo) ListSpaces

func (r *Repo) ListSpaces(ctx context.Context) (map[string]SpaceSpec, error)

ListSpaces lists all the spaces that the repository is configured to use

func (*Repo) Ls

func (r *Repo) Ls(ctx context.Context, mark FQM, p string, fn func(gotfs.DirEnt) error) error

func (*Repo) MarkLoad

func (r *Repo) MarkLoad(ctx context.Context, mark FQM) (*Snap, error)

MarkLoad loads the Snapshot that the mark points to.

func (*Repo) Modify

func (r *Repo) Modify(ctx context.Context, fqm FQM, fn func(mc marks.ModifyCtx) (*Snap, error)) error

Modify calls fn to modify the target of a Mark.

func (*Repo) NSVolume

func (r *Repo) NSVolume(ctx context.Context) (blobcache.FQOID, error)

NSVolume returns the FQOID of the namespace volume. This can be used to access the namespace from another Blobcache node. It does not modify the contents of the namespace volume.

func (*Repo) NSVolumeSpec

func (r *Repo) NSVolumeSpec(ctx context.Context) (*VolumeSpec, error)

func (*Repo) OrgClient

func (r *Repo) OrgClient(actAs string) (gotorg.Client, error)

func (*Repo) Serve

func (r *Repo) Serve(ctx context.Context, pc net.PacketConn) error

func (*Repo) Stat

func (r *Repo) Stat(ctx context.Context, mark FQM, p string) (*gotfs.Info, error)

func (*Repo) SyncSpaces

func (r *Repo) SyncSpaces(ctx context.Context, task SyncSpacesTask) error

SyncSpaces executes a SyncSpaceTask

func (*Repo) SyncUnit

func (r *Repo) SyncUnit(ctx context.Context, src, dst FQM, force bool) error

SyncUnit syncs 2 marks by name.

type Root

type Root = gotfs.Root

type Snap

type Snap = marks.Snap

type Space

type Space = marks.Space

type SpaceSpec

type SpaceSpec struct {
	// Blobcache is a arbitrary Blobcache Volume
	// The contents of the Volume are expected to be in the GotNS format.
	Blobcache *VolumeSpec `json:"bc,omitempty"`
	// Org is an arbitrary Blobcache Volume
	// The contents of the Volume are expected to be in the GotOrg format
	Org *blobcache.URL `json:"org,omitempty"`
}

type SyncSpacesTask

type SyncSpacesTask struct {
	// Src is name of the space to read from.
	Src string
	// Filter is applied to src to determine what to copy.
	// If nil, then all marks are copied.
	Filter func(string) bool
	// MapName is applied to go from names in the Src space, to name in the Dst space.
	MapName func(string) string
	// Dst is the name of the space to write to.
	Dst string
}

SyncSpacesTask contains parameters needed to copy marks from one space to another.

type Volume

type Volume = marks.Volume

type VolumeSpec

type VolumeSpec struct {
	URL    blobcache.URL `json:"url"`
	Secret gdat.DEK      `json:"secret"`
}

type WorkingCopyID

type WorkingCopyID = reposchema.StageID

func NewWorkingCopyID

func NewWorkingCopyID() WorkingCopyID

Directories

Path Synopsis
internal
reposchema
Package reposchema implements a Blobcache Schema for a Got Repo.
Package reposchema implements a Blobcache Schema for a Got Repo.

Jump to

Keyboard shortcuts

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