refstore

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckStagedFiles = os.Getenv("OCUROOT_CHECK_STAGED_FILES") != ""

CheckedStagedFiles uses `git add .` to validate that we have the correct set of staged files for each commit. Enabling this will make commits slower, but may be useful for debugging status problems.

View Source
var DEBUG_TRACES = os.Getenv("OCUROOT_DEBUG_TRACES") != ""
View Source
var ErrReadOnly = errors.New("read-only store")
View Source
var ErrRefNotFound = errors.New("ref not found")

Functions

func GitURLToValidPath added in v0.3.15

func GitURLToValidPath(gitURL string) string

func IncrementPath

func IncrementPath(ctx context.Context, store Store, pathPrefix string) (string, error)

Types

type FSStateStore

type FSStateStore struct {
	BasePath string
}

func NewFSRefStore

func NewFSRefStore(basePath string) (*FSStateStore, error)

func (*FSStateStore) ActualDependencyPaths

func (f *FSStateStore) ActualDependencyPaths(ctx context.Context, ref string, dependency string) (string, string)

func (*FSStateStore) ActualPath

func (f *FSStateStore) ActualPath(ref string) (string, error)

func (*FSStateStore) AddDependency

func (f *FSStateStore) AddDependency(ctx context.Context, ref string, dependency string) error

func (*FSStateStore) Close

func (f *FSStateStore) Close() error

Close implements RefStore.

func (*FSStateStore) CommitTransaction

func (f *FSStateStore) CommitTransaction(ctx context.Context) error

func (*FSStateStore) Delete

func (f *FSStateStore) Delete(ctx context.Context, ref string) error

Delete implements RefStore.

func (*FSStateStore) Get

func (f *FSStateStore) Get(ctx context.Context, ref string, v any) error

Get implements RefStore.

func (*FSStateStore) GetDependants

func (f *FSStateStore) GetDependants(ctx context.Context, ref string) ([]string, error)

func (*FSStateStore) GetDependencies

func (f *FSStateStore) GetDependencies(ctx context.Context, ref string) ([]string, error)
func (f *FSStateStore) GetLinks(ctx context.Context, ref string) ([]string, error)
func (f *FSStateStore) Link(ctx context.Context, ref string, target string) error

func (*FSStateStore) Match

func (f *FSStateStore) Match(ctx context.Context, glob ...string) ([]string, error)

Match implements RefStore.

func (*FSStateStore) MatchOptions

func (f *FSStateStore) MatchOptions(ctx context.Context, options MatchOptions, glob ...string) ([]string, error)

func (*FSStateStore) RemoveDependency

func (f *FSStateStore) RemoveDependency(ctx context.Context, ref string, dependency string) error
func (f *FSStateStore) ResolveLink(ctx context.Context, ref string) (string, error)

func (*FSStateStore) Set

func (f *FSStateStore) Set(ctx context.Context, ref string, v any) error

Set implements RefStore.

func (*FSStateStore) StartTransaction

func (f *FSStateStore) StartTransaction(ctx context.Context, message string) error
func (f *FSStateStore) Unlink(ctx context.Context, ref string) error

type GitRefStore

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

func NewGitRefStore

func NewGitRefStore(
	baseDir string,
	remote string,
	branch string,
	cfg GitRefStoreConfig,
) (*GitRefStore, error)

func (*GitRefStore) AddDependency

func (g *GitRefStore) AddDependency(ctx context.Context, ref string, dependency string) error

func (*GitRefStore) AddSupportFiles

func (g *GitRefStore) AddSupportFiles(ctx context.Context, files map[string]string) error

func (*GitRefStore) Close

func (g *GitRefStore) Close() error

func (*GitRefStore) CommitTransaction

func (g *GitRefStore) CommitTransaction(ctx context.Context) error

func (*GitRefStore) Delete

func (g *GitRefStore) Delete(ctx context.Context, ref string) error

func (*GitRefStore) Get

func (g *GitRefStore) Get(ctx context.Context, ref string, v any) error

func (*GitRefStore) GetDependants

func (g *GitRefStore) GetDependants(ctx context.Context, ref string) ([]string, error)

func (*GitRefStore) GetDependencies

func (g *GitRefStore) GetDependencies(ctx context.Context, ref string) ([]string, error)
func (g *GitRefStore) GetLinks(ctx context.Context, ref string) ([]string, error)
func (g *GitRefStore) Link(ctx context.Context, ref string, target string) error

func (*GitRefStore) Match

func (g *GitRefStore) Match(ctx context.Context, glob ...string) ([]string, error)

func (*GitRefStore) MatchOptions

func (g *GitRefStore) MatchOptions(ctx context.Context, options MatchOptions, glob ...string) ([]string, error)

func (*GitRefStore) RemoveDependency

func (g *GitRefStore) RemoveDependency(ctx context.Context, ref string, dependency string) error
func (g *GitRefStore) ResolveLink(ctx context.Context, ref string) (string, error)

func (*GitRefStore) Set

func (g *GitRefStore) Set(ctx context.Context, ref string, v any) error

func (*GitRefStore) StartTransaction

func (g *GitRefStore) StartTransaction(ctx context.Context, message string) error
func (g *GitRefStore) Unlink(ctx context.Context, ref string) error

type GitRefStoreConfig added in v0.3.15

type GitRefStoreConfig struct {
	GitRepoConfig

	PathPrefix string
}

type GitRepo

type GitRepo interface {
	RepoPath() string
	Branch() string
	// contains filtered or unexported methods
}

func GitRepoWithOtel

func GitRepoWithOtel(repo GitRepo) GitRepo

func NewGitRepoForRemote

func NewGitRepoForRemote(baseDir, remote, branch string, cfg GitRepoConfig) (GitRepo, error)

type GitRepoConfig added in v0.3.15

type GitRepoConfig struct {
	CreateBranch bool

	GitUserName  string
	GitUserEmail string
}

type GitRepoWrapper

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

func (*GitRepoWrapper) Branch

func (g *GitRepoWrapper) Branch() string

func (*GitRepoWrapper) RepoPath

func (g *GitRepoWrapper) RepoPath() string

type GitRepoWrapperWithOtel

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

func (*GitRepoWrapperWithOtel) Branch

func (g *GitRepoWrapperWithOtel) Branch() string

Branch implements GitRepo.

func (*GitRepoWrapperWithOtel) RepoPath

func (g *GitRepoWrapperWithOtel) RepoPath() string

RepoPath implements GitRepo.

type GitSupportFileWriter

type GitSupportFileWriter interface {
	// AddSupportFiles creates a set of files in the git repository outside of
	// the state store contents.
	// It can be used to add CI configuration files to a repo, for example
	AddSupportFiles(ctx context.Context, files map[string]string) error
}

type MatchOptions

type MatchOptions struct {
	NoLinks bool
}

type PathResolver

type PathResolver interface {
	ActualPath(ref string) (string, error)
	ActualDependencyPaths(ctx context.Context, ref string, dependency string) (string, string)
}

type ReadOnlyStore

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

func (*ReadOnlyStore) AddDependency

func (r *ReadOnlyStore) AddDependency(ctx context.Context, ref string, dependency string) error

AddDependency implements RefStore.

func (*ReadOnlyStore) Close

func (r *ReadOnlyStore) Close() error

Close implements RefStore.

func (*ReadOnlyStore) CommitTransaction

func (r *ReadOnlyStore) CommitTransaction(ctx context.Context) error

CommitTransaction implements RefStore.

func (*ReadOnlyStore) Delete

func (r *ReadOnlyStore) Delete(ctx context.Context, ref string) error

Delete implements RefStore.

func (*ReadOnlyStore) Get

func (r *ReadOnlyStore) Get(ctx context.Context, ref string, v any) error

Get implements RefStore.

func (*ReadOnlyStore) GetDependants

func (r *ReadOnlyStore) GetDependants(ctx context.Context, ref string) ([]string, error)

GetDependants implements RefStore.

func (*ReadOnlyStore) GetDependencies

func (r *ReadOnlyStore) GetDependencies(ctx context.Context, ref string) ([]string, error)

GetDependencies implements RefStore.

func (r *ReadOnlyStore) GetLinks(ctx context.Context, ref string) ([]string, error)

GetLinks implements RefStore.

func (r *ReadOnlyStore) Link(ctx context.Context, ref string, target string) error

Link implements RefStore.

func (*ReadOnlyStore) Match

func (r *ReadOnlyStore) Match(ctx context.Context, glob ...string) ([]string, error)

Match implements RefStore.

func (*ReadOnlyStore) MatchOptions

func (r *ReadOnlyStore) MatchOptions(ctx context.Context, options MatchOptions, glob ...string) ([]string, error)

MatchOptions implements RefStore.

func (*ReadOnlyStore) RemoveDependency

func (r *ReadOnlyStore) RemoveDependency(ctx context.Context, ref string, dependency string) error

RemoveDependency implements RefStore.

func (r *ReadOnlyStore) ResolveLink(ctx context.Context, ref string) (string, error)

ResolveLink implements RefStore.

func (*ReadOnlyStore) Set

func (r *ReadOnlyStore) Set(ctx context.Context, ref string, v any) error

Set implements RefStore.

func (*ReadOnlyStore) StartTransaction

func (r *ReadOnlyStore) StartTransaction(ctx context.Context, message string) error

StartTransaction implements RefStore.

func (r *ReadOnlyStore) Unlink(ctx context.Context, ref string) error

Unlink implements RefStore.

type StorageKind

type StorageKind string
const (
	StorageKindRef  StorageKind = "ref"
	StorageKindLink StorageKind = "link"
)

type StorageObject

type StorageObject struct {
	Kind        StorageKind     `json:"kind"`
	BodyType    string          `json:"body_type,omitempty"`
	CreateStack []string        `json:"create_stack,omitempty"`
	SetStack    []string        `json:"set_stack,omitempty"`
	Links       []string        `json:"links,omitempty"`
	Body        json.RawMessage `json:"body"`
}

type Store

type Store interface {
	StartTransaction(ctx context.Context, message string) error
	CommitTransaction(ctx context.Context) error

	Get(ctx context.Context, ref string, v any) error
	Set(ctx context.Context, ref string, v any) error
	Delete(ctx context.Context, ref string) error

	// Match will return all the refs matching the provided glob patterns
	// See: https://en.wikipedia.org/wiki/Glob_(programming)
	Match(ctx context.Context, glob ...string) ([]string, error)
	MatchOptions(ctx context.Context, options MatchOptions, glob ...string) ([]string, error)

	// Link will create a new ref that points to the target ref
	Link(ctx context.Context, ref string, target string) error
	Unlink(ctx context.Context, ref string) error
	GetLinks(ctx context.Context, ref string) ([]string, error)
	ResolveLink(ctx context.Context, ref string) (string, error)

	// Dependencies track dependency relationships between refs
	AddDependency(ctx context.Context, ref string, dependency string) error
	RemoveDependency(ctx context.Context, ref string, dependency string) error
	GetDependencies(ctx context.Context, ref string) ([]string, error)
	GetDependants(ctx context.Context, ref string) ([]string, error)

	Close() error
}

func ListenToStateChanges

func ListenToStateChanges(f func(ctx context.Context, ref string), store Store, filters ...string) (Store, error)

func NewReadOnlyStore

func NewReadOnlyStore(store Store) Store

func StoreWithOtel

func StoreWithOtel(store Store) Store

type StoreInfo

type StoreInfo struct {
	Version int `json:"version"`
}

type WithOtel

type WithOtel struct {
	Store Store
	// contains filtered or unexported fields
}

func (*WithOtel) AddDependency

func (w *WithOtel) AddDependency(ctx context.Context, ref string, dependency string) error

AddDependency implements Store.

func (*WithOtel) AddSupportFiles

func (w *WithOtel) AddSupportFiles(ctx context.Context, files map[string]string) error

func (*WithOtel) Close

func (w *WithOtel) Close() error

Close implements Store.

func (*WithOtel) CommitTransaction

func (w *WithOtel) CommitTransaction(ctx context.Context) error

CommitTransaction implements Store.

func (*WithOtel) Delete

func (w *WithOtel) Delete(ctx context.Context, ref string) error

Delete implements Store.

func (*WithOtel) Get

func (w *WithOtel) Get(ctx context.Context, ref string, v any) error

Get implements Store.

func (*WithOtel) GetDependants

func (w *WithOtel) GetDependants(ctx context.Context, ref string) ([]string, error)

GetDependants implements Store.

func (*WithOtel) GetDependencies

func (w *WithOtel) GetDependencies(ctx context.Context, ref string) ([]string, error)

GetDependencies implements Store.

func (w *WithOtel) GetLinks(ctx context.Context, ref string) ([]string, error)

GetLinks implements Store.

func (w *WithOtel) Link(ctx context.Context, ref string, target string) error

Link implements Store.

func (*WithOtel) Match

func (w *WithOtel) Match(ctx context.Context, glob ...string) ([]string, error)

Match implements Store.

func (*WithOtel) MatchOptions

func (w *WithOtel) MatchOptions(ctx context.Context, options MatchOptions, glob ...string) ([]string, error)

MatchOptions implements Store.

func (*WithOtel) RemoveDependency

func (w *WithOtel) RemoveDependency(ctx context.Context, ref string, dependency string) error

RemoveDependency implements Store.

func (w *WithOtel) ResolveLink(ctx context.Context, ref string) (string, error)

ResolveLink implements Store.

func (*WithOtel) Set

func (w *WithOtel) Set(ctx context.Context, ref string, v any) error

Set implements Store.

func (*WithOtel) StartTransaction

func (w *WithOtel) StartTransaction(ctx context.Context, message string) error

StartTransaction implements Store.

func (w *WithOtel) Unlink(ctx context.Context, ref string) error

Unlink implements Store.

Jump to

Keyboard shortcuts

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