stack

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package stack resolves a coordination composition: which component repositories participate, where each one mounts in the realization, which display name each one resolves to, and — with the runtime catalog and sparse overrides — the exact activation plan a Release snapshots.

Everything here is pure: callers supply pinned component configuration and catalogs (read from Git in internal/controlplane/gitops), and get back either a resolved composition or the complete list of problems. Nothing performs I/O, and nothing fails on the first problem — an operator fixing a composition wants to see all of it at once.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidComposition = errors.New("stack: composition is not valid")

ErrInvalidComposition lets callers errors.Is a *CompositionError.

Functions

func MountFor

func MountFor(mount string, desc domain.ComponentDescriptor, resourcePath string) (string, error)

MountFor returns the realization-relative directory of one resource: the component mount for a single-resource component, or the mount joined with the resource's catalog path for a collection.

func ProposeMount

func ProposeMount(displayName string, desc domain.ComponentDescriptor) (string, error)

ProposeMount suggests the mount for a newly detected component: a bracketed category named after the repository for a collection, and the resource directory inside a category of its own name for a single resource.

func ResolvePlan

func ResolvePlan(in PlanInput) (Plan, []Problem)

ResolvePlan builds the activation plan or returns every problem.

func SortComponents

func SortComponents(comps []Component)

SortComponents orders components by repository ID so every derived document is deterministic regardless of stack file order.

Types

type Component

type Component struct {
	// Spec is the coordination record (remote, mount, alias, override).
	Spec domain.StackComponent
	// Commit is the resolved full commit id.
	Commit string
	// Config is the component's committed .fxvcs/repository.yaml at Commit.
	Config *domain.Repository
	// Catalog is the component's committed .fxvcs/resources.yaml at Commit
	// (nil for a non-FiveM component).
	Catalog *domain.ResourceCatalog
	// AssetRoot is the digest of the canonical asset index of the pinned tree.
	AssetRoot string
}

Component is one pinned component of a composition.

func (Component) Descriptor

func (c Component) Descriptor() (domain.ComponentDescriptor, string)

Descriptor returns the accepted layout descriptor and its provenance. The component owns its source root and layout; coordination may record an explicit reviewed override, and the Release snapshots which one was used.

func (Component) DisplayName

func (c Component) DisplayName() string

DisplayName is the coordination alias when one is recorded, otherwise the component's own metadata.name. Display names never enter sourceSetDigest.

func (Component) OverridesComponent

func (c Component) OverridesComponent() bool

OverridesComponent reports that coordination recorded a descriptor that disagrees with the component's own. It is legal — that is what an override is for — but it is always surfaced, because it changes the realization shape without any change in the component repository.

type CompositionError

type CompositionError struct{ Problems []Problem }

CompositionError aggregates every problem found in one pass.

func (*CompositionError) Error

func (e *CompositionError) Error() string

func (*CompositionError) Is

func (e *CompositionError) Is(target error) bool

type Override

type Override struct {
	// Selector is a resource name, a "<repositoryID>:<path>" component
	// identity, or a "runtime:"/"external:" resource ID.
	Selector string
	// Activation is enabled or disabled.
	Activation domain.Activation
}

Override is one release-only activation choice.

type Plan

type Plan struct {
	Resources        []domain.ReleaseResource
	RuntimeResources []domain.RuntimeResource
}

Plan is the resolved activation plan plus the runtime entries it needs.

func (Plan) EnabledNames

func (p Plan) EnabledNames() []string

EnabledNames returns the names the generated cfg would ensure, in order.

type PlanInput

type PlanInput struct {
	// Components are the pinned components, already validated.
	Components []Component
	// Runtime is the coordination-owned runtime/external catalog.
	Runtime *domain.RuntimeResourceCatalog
	// Overrides is the coordination override file.
	Overrides *domain.ResourceOverrides
	// ReleaseOverrides are release-only --enable/--disable choices.
	ReleaseOverrides []Override
}

PlanInput is everything the planner needs.

type Problem

type Problem struct {
	// Component is the repositoryID the problem belongs to ("" for
	// composition-wide problems).
	Component string `json:"component,omitempty"`
	Field     string `json:"field"`
	Message   string `json:"message"`
}

Problem is one composition finding.

func ValidateComposition

func ValidateComposition(comps []Component) []Problem

ValidateComposition checks everything that must hold across components before a Release may be built: identity uniqueness, descriptor/mount agreement, mount containment and overlap, category semantics, and resolved display-name uniqueness. It returns every problem it finds.

func (Problem) String

func (p Problem) String() string

Jump to

Keyboard shortcuts

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