Documentation
¶
Overview ¶
Package gitops implements the coordination control plane over an ordinary Git repository (ADR 0004).
Layout, from docs/spec/schemas.md and product scope §8:
fxvcs.yaml Stack: composition, components, mounts runtime-resources.yaml RuntimeResourceCatalog: runtime:/external: entries resource-overrides.yaml ResourceOverrides: sparse activation/order overrides releases/<name>.yaml Release (immutable once committed) environments/<name>.yaml Environment targets/<name>.yaml Target
Every write lands in the working tree as reviewable YAML. Nothing here runs `git commit`, `git push`, or `git tag`: making a change authoritative is a human/CI review step, which is the whole point of a GitOps control plane.
Index ¶
- Constants
- Variables
- func IsCommitID(s string) bool
- func LoadStack(root string) (*domain.Stack, error)
- func Locate(start string) (string, error)
- func ValidateName(kind, name string) error
- type DocumentError
- type FS
- type Options
- type Repo
- func (r *Repo) Component(repositoryID string) (domain.StackComponent, bool)
- func (r *Repo) EnvironmentPath(name string) string
- func (r *Repo) GetEnvironment(name string) (domain.Environment, error)
- func (r *Repo) GetRelease(_ context.Context, name string) (domain.Release, error)
- func (r *Repo) GetTarget(_ context.Context, name string) (domain.Target, error)
- func (r *Repo) HasMirror(repositoryID string) bool
- func (r *Repo) ListEnvironments() ([]string, error)
- func (r *Repo) ListReleases() ([]string, error)
- func (r *Repo) ListTargets() ([]string, error)
- func (r *Repo) MirrorPath(repositoryID string) (string, error)
- func (r *Repo) Overrides() (*domain.ResourceOverrides, error)
- func (r *Repo) Path(parts ...string) string
- func (r *Repo) Rel(abs string) string
- func (r *Repo) ReleasePath(name string) string
- func (r *Repo) RemoteHasRef(ctx context.Context, comp domain.StackComponent, commit string) (bool, error)
- func (r *Repo) ResolveRef(ctx context.Context, repositoryID, ref string) (string, error)
- func (r *Repo) RuntimeResources() (*domain.RuntimeResourceCatalog, error)
- func (r *Repo) SaveEnvironment(env domain.Environment) (string, error)
- func (r *Repo) SaveRuntimeResources(cat *domain.RuntimeResourceCatalog) error
- func (r *Repo) SaveStack(ws *domain.Stack) error
- func (r *Repo) SaveTarget(t domain.Target) (string, error)
- func (r *Repo) SetTargetRelease(ctx context.Context, target, release string) error
- func (r *Repo) SyncComponent(ctx context.Context, comp domain.StackComponent) error
- func (r *Repo) TagComponent(ctx context.Context, comp domain.StackComponent, tag, commit, message string) error
- func (r *Repo) TargetPath(name string) string
- func (r *Repo) Tree(ctx context.Context, repositoryID, commit string) (*Tree, error)
- func (r *Repo) WriteRelease(ctx context.Context, rel domain.Release) (path string, rewritten bool, err error)
- type Tree
- func (t *Tree) CopyBlob(ctx context.Context, oid string, w io.Writer) error
- func (t *Tree) Entries(ctx context.Context) ([]TreeEntry, error)
- func (t *Tree) FS(ctx context.Context) (*FS, error)
- func (t *Tree) ReadBlob(ctx context.Context, oid string) ([]byte, error)
- func (t *Tree) ReadFile(ctx context.Context, path string) ([]byte, error)
- func (t *Tree) RepositoryConfig(ctx context.Context) (*domain.Repository, error)
- func (t *Tree) ResourceCatalog(ctx context.Context) (*domain.ResourceCatalog, error)
- type TreeEntry
Constants ¶
const ( StackFile = "fxvcs.yaml" RuntimeResourcesFile = "runtime-resources.yaml" OverridesFile = "resource-overrides.yaml" ReleasesDir = "releases" EnvironmentsDir = "environments" TargetsDir = "targets" )
File names and directories of the coordination layout.
Variables ¶
var ErrNotStack = errors.New("gitops: not a coordination repository")
ErrNotStack is returned when no coordination repository is found.
Functions ¶
func IsCommitID ¶
IsCommitID reports whether s is a full SHA-1 or SHA-256 object name.
func LoadStack ¶
LoadStack reads and validates fxvcs.yaml at the given repository root without opening Git or enforcing the installed-version compatibility gate.
func ValidateName ¶
ValidateName checks a release, environment, or target name.
Types ¶
type DocumentError ¶
DocumentError names the file a validation failure came from.
func (*DocumentError) Error ¶
func (e *DocumentError) Error() string
func (*DocumentError) Unwrap ¶
func (e *DocumentError) Unwrap() error
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS presents a pinned component commit as a read-only fs.FS so the FiveM discovery and manifest-sandbox packages can scan it exactly as they scan a working tree. Release creation must re-scan the *pinned* tree, not whatever happens to be checked out, and this is the seam that makes those two code paths the same code path.
Blob contents are read on demand and memoised; directory structure is derived once from `ls-tree -r`. Symlinks and gitlinks are not exposed: a manifest scanner that followed one could leave the commit it is supposed to be describing.
type Repo ¶
type Repo struct {
// Root is the working-tree top level holding fxvcs.yaml.
Root string
// GitDir is the coordination repository's $GIT_DIR; component mirrors and
// other derived state live under GitDir/fxvcs.
GitDir string
// Stack is the parsed fxvcs.yaml.
Stack *domain.Stack
// Git runs against Root.
Git *gitclient.Client
// contains filtered or unexported fields
}
Repo is an opened coordination repository.
func Init ¶
func Init(ctx context.Context, root string, ws *domain.Stack, adopt bool, opts Options) (*Repo, error)
Init creates or adopts a coordination repository at root. The directory must already be a Git working tree (`stack init` refuses to guess where a new repository belongs); an existing fxvcs.yaml is an error unless adopt is set, in which case the existing file is loaded unchanged.
func (*Repo) Component ¶
func (r *Repo) Component(repositoryID string) (domain.StackComponent, bool)
Component returns the stack component with the given repository ID.
func (*Repo) EnvironmentPath ¶
EnvironmentPath is the file an environment name maps to.
func (*Repo) GetEnvironment ¶
func (r *Repo) GetEnvironment(name string) (domain.Environment, error)
GetEnvironment loads one environment.
func (*Repo) GetRelease ¶
GetRelease implements controlplane.ControlPlane.
func (*Repo) ListEnvironments ¶
ListEnvironments returns environment names in lexical order.
func (*Repo) ListReleases ¶
ListReleases returns release names in lexical order.
func (*Repo) ListTargets ¶
ListTargets returns target names in lexical order.
func (*Repo) MirrorPath ¶
MirrorPath returns the bare mirror directory for a component.
func (*Repo) Overrides ¶
func (r *Repo) Overrides() (*domain.ResourceOverrides, error)
Overrides loads resource-overrides.yaml; a missing file means no overrides.
func (*Repo) ReleasePath ¶
ReleasePath is the file a release name maps to.
func (*Repo) RemoteHasRef ¶
func (r *Repo) RemoteHasRef(ctx context.Context, comp domain.StackComponent, commit string) (bool, error)
RemoteHasRef reports whether the component's Git remote still advertises a ref pointing at commit. Release creation uses it to warn that a pin is not reachable from a durable advertised ref.
func (*Repo) ResolveRef ¶
ResolveRef resolves a branch, tag, or SHA in a component mirror to a full commit ID. A ref that does not exist locally is not silently fetched: the caller decides when the network is allowed.
func (*Repo) RuntimeResources ¶
func (r *Repo) RuntimeResources() (*domain.RuntimeResourceCatalog, error)
RuntimeResources loads runtime-resources.yaml; a missing file is an empty catalog, because a composition made only of component repositories is legitimate.
func (*Repo) SaveEnvironment ¶
func (r *Repo) SaveEnvironment(env domain.Environment) (string, error)
SaveEnvironment writes one environment record.
func (*Repo) SaveRuntimeResources ¶
func (r *Repo) SaveRuntimeResources(cat *domain.RuntimeResourceCatalog) error
SaveRuntimeResources writes runtime-resources.yaml.
func (*Repo) SaveTarget ¶
SaveTarget writes one target record.
func (*Repo) SetTargetRelease ¶
SetTargetRelease implements controlplane.ControlPlane. It edits desired state in the working tree; the change becomes authoritative only when a human or CI commits and pushes it.
func (*Repo) SyncComponent ¶
SyncComponent creates the mirror if needed and fetches all branches and tags from the component's remote. It is the only operation in this package that touches the network.
func (*Repo) TagComponent ¶
func (r *Repo) TagComponent(ctx context.Context, comp domain.StackComponent, tag, commit, message string) error
TagComponent creates an annotated tag in the component's remote naming the pinned commit. It is only reached through `release create --tag-components`, which plans every tag first and never accepts partial tagging as success.
func (*Repo) TargetPath ¶
TargetPath is the file a target name maps to.
func (*Repo) WriteRelease ¶
func (r *Repo) WriteRelease(ctx context.Context, rel domain.Release) (path string, rewritten bool, err error)
WriteRelease writes a new release record. A release name is permanently bound to its content digest: writing over an existing record is refused unless the semantic content is identical, in which case the write is a no-op and rewritten reports false.
type Tree ¶
Tree reads one pinned component commit.
func (*Tree) ReadFile ¶
ReadFile returns the bytes of one path in the pinned tree. A missing path returns controlplane.ErrNotFound.
func (*Tree) RepositoryConfig ¶
RepositoryConfig loads the component's committed .fxvcs/repository.yaml from the pinned tree. This is what makes a component self-describing: its accepted source root and layout travel with the commit, so composition never has to guess them.
func (*Tree) ResourceCatalog ¶
ResourceCatalog loads the component's committed .fxvcs/resources.yaml. A component with no catalog returns controlplane.ErrNotFound so the caller can say which repository needs `fxvcs resources sync`.
type TreeEntry ¶
type TreeEntry struct {
// Path is the normalized repository-relative path.
Path string
// Mode is the Git file mode ("100644", "100755", "120000", "160000").
Mode string
// OID is the blob object name.
OID string
// Size is the blob size in bytes.
Size int64
}
TreeEntry is one blob of a pinned component tree.