loader

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 58 Imported by: 0

Documentation

Overview

Package loader hydrates a Store from Flux source filesystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppliesToEntry added in v0.7.3

func AppliesToEntry(
	s sourceStore,
	application *manifest.EntryApplication,
	input *store.SourceArtifact,
	entry string,
) bool

AppliesToEntry reports whether a resolved application reads the admitted entry.

func Claims added in v0.7.3

func Claims(s *store.Store, repoRoot string, candidates []*manifest.Kustomization) []manifest.KSClaim

Claims builds reporting claims from caller-owned candidates, including external sources and committed source coordinates. Discovery MUST use Loader.Claims instead.

func LoadDocuments added in v0.7.3

func LoadDocuments(ctx context.Context, r io.Reader, path string) ([]store.Declaration, error)

LoadDocuments prepares required invocation declarations without exposing payloads in errors.

func ParseChildren added in v0.7.3

func ParseChildren(
	parent manifest.BaseManifest,
	docs []manifest.DocOccurrence,
	opts manifest.ParseDocOptions,
	skipKinds []string,
) store.ChildDocuments

ParseChildren selects output and retains authoritative sanitized child documents. Producer namespace policy overrides opts.DefaultNamespace; raw parents use that default. The returned objects and maps MUST remain immutable after publication.

func Prepare added in v0.7.3

Prepare admits one authoritative document while retaining its sanitized outcome.

func Promote added in v0.7.3

func Promote(
	ctx context.Context,
	st *store.Store,
	id manifest.NamedResource,
	opts PromoteOptions,
) ([]store.Child, error)

Promote acquires exact children; callers must admit the generation before publication.

func ValidateDeclarations added in v0.7.3

func ValidateDeclarations(children []store.Declaration) error

ValidateDeclarations requires authored identity against all invocation definitions.

Types

type BuiltInput added in v0.7.3

type BuiltInput struct {
	Root          string
	Owner, Source manifest.NamedResource
	Reads         map[string]bool
	// RegisterBuilt owns Support on every call, including rejection.
	Support *store.ReadSet
}

BuiltInput binds prepared documents and observed source-relative reads to their ordinary producer.

type Catalog added in v0.7.3

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

Catalog borrows immutable loader facts until its owner calls Close.

func (*Catalog) CatalogObject added in v0.7.3

func (c *Catalog) CatalogObject(id manifest.NamedResource) manifest.BaseManifest

CatalogObject borrows the declaration with its effective identity.

func (*Catalog) Close added in v0.7.3

func (c *Catalog) Close()

Close releases borrowed catalog storage and is safe to repeat.

func (*Catalog) RootEvidence added in v0.7.3

func (c *Catalog) RootEvidence(id manifest.NamedResource, reads *store.ReadSet) selection.RootEvidence

RootEvidence captures current support without retaining the supplied read set.

func (*Catalog) SourceExternal added in v0.7.3

func (c *Catalog) SourceExternal(id manifest.NamedResource, reads *store.ReadSet) bool

SourceExternal uses the caller's capture so replacement invalidates the observation.

type Loader

type Loader struct {
	Store   *store.Store
	Options options
	// SourceRoot anchors slash-separated discovery coordinates and bounds
	// standalone input admission. Source artifacts supply their own FS.
	SourceRoot string

	// Index records static discovery facts and is initialized by New. Caller
	// replacements MUST initialize Records before Load. Mutable until FinalizeIndex returns.
	Index *manifest.DiscoveryIndex
	// InputContent contains transient evidence paired with the current derived index.
	InputContent map[manifest.NamedResource]inputprojection.Projection

	// IgnoreFile, when non-empty, is the gitignore-grammar file Load
	// reads in place of <root>/.krmignore, with its patterns anchored
	// at the Load root. Discovery sets it for the --path scan only:
	// spec.path targets followed afterwards keep their own
	// per-directory .krmignore, exactly as if the file sat at the
	// scan root.
	IgnoreFile string

	// PreferExisting suppresses overwrites of resources already in
	// the store and their discovery records. Used by the
	// orchestrator's recursive spec.path discovery so the initial
	// --path scan's data wins over downstream paths that may point
	// into a different tree.
	PreferExisting bool
	// contains filtered or unexported fields
}

Loader collects source-qualified discovery evidence before admitting roots. Source membership MUST remain stable across sequential Load calls. The first Load classifies the entry for all subsequent loads; independent entry policies require separate loaders.

func New

func New(s *store.Store) *Loader

New initializes discovery state.

func (*Loader) AdmissionCandidate added in v0.7.3

func (l *Loader) AdmissionCandidate(id manifest.NamedResource) store.Child

AdmissionCandidate borrows the immutable declaration prepared during construction.

func (*Loader) Admit added in v0.7.3

func (l *Loader) Admit(repoRoot string)

Admit resolves scope evidence and publishes independently runnable discovery roots.

func (*Loader) AdmitDeclarations added in v0.7.3

func (l *Loader) AdmitDeclarations(children []store.Declaration)

AdmitDeclarations retains pathless reference evidence before repository discovery.

func (*Loader) BuiltChildren added in v0.7.3

func (l *Loader) BuiltChildren(root string, owner manifest.NamedResource, reads *store.ReadSet) ([]store.Child, bool)

BuiltChildren requires current construction membership and the original preparation capture.

func (*Loader) CatalogObject added in v0.7.3

func (l *Loader) CatalogObject(id manifest.NamedResource) manifest.BaseManifest

CatalogObject returns immutable reporting facts without hydrating or admitting the declaration.

func (*Loader) Claims added in v0.7.3

func (l *Loader) Claims(repoRoot string) []manifest.KSClaim

Claims reuses discovery's source-view documents while the Loader is mutable.

func (*Loader) Close added in v0.7.3

func (l *Loader) Close()

Close MUST follow every loader and catalog consumer and preserve detached result data.

func (*Loader) DetachCatalog added in v0.7.3

func (l *Loader) DetachCatalog() *Catalog

DetachCatalog keeps borrowed catalog facts alive beyond Loader.Close.

func (*Loader) EntryFailure added in v0.7.3

func (l *Loader) EntryFailure(ctx context.Context, repoRoot string) error

EntryFailure assesses retained failures admitted as unowned native entry resources.

func (*Loader) EntryFrontier added in v0.7.3

func (l *Loader) EntryFrontier(ctx context.Context, input *store.SourceArtifact, path string) (bool, error)

EntryFrontier must conservatively retain packages whose applications cannot be ruled out.

func (*Loader) EntryRoots added in v0.7.3

func (l *Loader) EntryRoots(
	published iter.Seq[manifest.BaseManifest],
	reads *store.ReadSet,
) []selection.OccurrenceFacts

EntryRoots MUST use captured admission evidence without I/O or publication.

func (*Loader) FinalizeIndex added in v0.7.3

func (l *Loader) FinalizeIndex(ctx context.Context, repoRoot string, freeze bool) error

FinalizeIndex freezes source-qualified graph contributions before reconciliation.

func (*Loader) IndexedObject added in v0.7.3

IndexedObject returns the retained declaration under its contextual identity.

func (*Loader) IsFileIndexed added in v0.7.3

func (l *Loader) IsFileIndexed(id manifest.NamedResource) bool

IsFileIndexed reports whether source input supplies an authoritative declaration for id.

func (*Loader) Kustomizations added in v0.7.3

func (l *Loader) Kustomizations() []store.Child

Kustomizations returns eligible source-qualified owner evidence.

func (*Loader) Load

func (l *Loader) Load(
	ctx context.Context,
	root string,
	owner manifest.NamedResource,
	work *manifest.WorkRecord,
) (_ int, resultErr error)

Load records Flux objects under root by walking the kustomize resource graph. When root has a kustomization.yaml it's treated as a kustomize package and only files reachable through `resources:` are loaded; when it has none, a recursive walk finds and enters kustomize packages it encounters, loading every YAML otherwise.

Honors ctx cancellation; visited-set protects against cycles.

func (*Loader) Occurrence added in v0.7.3

Occurrence borrows exact declaration coordinates and immutable parsed facts.

func (*Loader) OccurrenceClaims added in v0.7.3

func (l *Loader) OccurrenceClaims(repoRoot string, occurrences []selection.OccurrenceFacts) []manifest.KSClaim

OccurrenceClaims derives claims from mounted source views without admitting document identities.

func (*Loader) OccurrenceObject added in v0.7.3

func (l *Loader) OccurrenceObject(
	ctx context.Context,
	occurrenceValue *selection.OccurrenceFacts,
	input *store.SourceArtifact,
) (store.Child, error)

OccurrenceObject MUST hydrate only the declaration in its admitted source view.

func (*Loader) OccurrenceRoots added in v0.7.3

func (l *Loader) OccurrenceRoots(id manifest.NamedResource) (manifest.NamedResource, []string)

OccurrenceRoots borrows the parsed render paths in the effective source namespace.

func (*Loader) Occurrences added in v0.7.3

func (l *Loader) Occurrences(ctx context.Context, dir, targetNamespace string) ([]selection.OccurrenceFacts, error)

Occurrences projects cached declarations through the existing contextual traversal.

func (*Loader) Packages added in v0.7.3

func (l *Loader) Packages(ctx context.Context) ([]PackageEvidence, error)

Packages snapshots resource graph inputs already traversed by Load.

func (*Loader) ParsedInputs added in v0.7.3

func (l *Loader) ParsedInputs() *ParsedInputs

ParsedInputs snapshots parsed bodies without retaining entry admission state.

func (*Loader) PathObjects added in v0.7.3

func (l *Loader) PathObjects() []selection.OccurrenceFacts

PathObjects returns live path witnesses, retaining occurrences until construction completes.

func (*Loader) PersistInputs added in v0.7.3

func (l *Loader) PersistInputs(ctx context.Context) error

PersistInputs publishes only content-certified authored facts through the cache owner.

func (*Loader) PreparedObject added in v0.7.3

func (l *Loader) PreparedObject(id manifest.NamedResource, reads *store.ReadSet) (store.Child, bool)

PreparedObject captures only the requested indexed document and its build support.

func (*Loader) ProducerFacts added in v0.7.3

func (l *Loader) ProducerFacts(object manifest.BaseManifest) selection.ProducerFacts

ProducerFacts reuses immutable projections across concurrent preparations.

func (*Loader) PromoteOrphans added in v0.7.3

func (l *Loader) PromoteOrphans(ctx context.Context) error

PromoteOrphans MUST run after index finalization.

func (*Loader) PromotionDocuments added in v0.7.3

func (l *Loader) PromotionDocuments(id manifest.NamedResource) []store.Child

PromotionDocuments returns the immutable indexed batch used to promote id.

func (*Loader) ReferenceFacts added in v0.7.3

ReferenceFacts resolves data against the current discovery index before publication.

func (*Loader) References added in v0.7.3

func (l *Loader) References(id manifest.NamedResource) iter.Seq[manifest.Reference]

References yields immutable authored reference evidence without hydrating its declaration.

func (*Loader) RegisterBuilt added in v0.7.3

func (l *Loader) RegisterBuilt(
	input BuiltInput,
	docs []store.Child,
)

RegisterBuilt replaces package resource evidence with authoritative producer-bound documents. Documents MUST be sanitized immutable build output.

func (*Loader) ResolveRoot added in v0.7.3

func (l *Loader) ResolveRoot(
	ctx context.Context,
	reads *store.ReadSet,
	source manifest.NamedResource,
	root string,
) (string, bool, error)

ResolveRoot confines traversal to a valid captured source artifact.

func (*Loader) Retire added in v0.7.3

func (l *Loader) Retire()

Retire releases admission readers while preserving completed owners' read tracking.

func (*Loader) RootEvidence added in v0.7.3

func (l *Loader) RootEvidence(id manifest.NamedResource, reads *store.ReadSet) selection.RootEvidence

RootEvidence captures physical support without consulting selection membership.

func (*Loader) SelectionIndex added in v0.7.3

func (l *Loader) SelectionIndex() *manifest.DiscoveryIndex

SelectionIndex borrows the loader-owned census; callers must not mutate it.

func (*Loader) SourceFacts added in v0.7.3

func (l *Loader) SourceFacts(source manifest.NamedResource, reads *store.ReadSet) selection.SourceFacts

SourceFacts borrows comparison facts while capturing current source authority.

func (*Loader) Sources added in v0.7.3

func (l *Loader) Sources(ctx context.Context) iter.Seq2[store.Child, error]

Sources yields eligible immutable source-artifact evidence in unspecified order.

func (*Loader) SweepPreparations added in v0.7.3

func (l *Loader) SweepPreparations()

SweepPreparations MUST run at a serial construction or quiescent runtime boundary.

type PackageEvidence added in v0.7.3

type PackageEvidence struct {
	Path        string
	Scans       []string
	Occurrences []selection.OccurrenceFacts
	Independent bool
}

PackageEvidence retains package provenance and shared root admission.

type ParsedInputs added in v0.7.3

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

ParsedInputs retains immutable parsed content from exact admitted source views.

func (*ParsedInputs) Matches added in v0.7.3

func (p *ParsedInputs) Matches(input *store.SourceArtifact) bool

Matches reports whether input owns a source view retained by these parsed facts.

type PromoteOptions added in v0.7.3

type PromoteOptions struct {
	Record    manifest.Production
	Reads     *store.ReadSet
	Documents []store.Child
}

PromoteOptions binds acquisition to an exact source and captured generation.

type SourceLocation added in v0.7.3

type SourceLocation struct {
	Path             string
	Pinned, External bool
}

SourceLocation binds a source path to its pin and ownership.

func SourceView added in v0.7.3

func SourceView(s sourceStore, ref manifest.NamedResource, repoRoot string) SourceLocation

SourceView classifies an admitted source coordinate, committed pin and external ownership. Unavailable sources MUST NOT borrow bootstrap bytes or claim unrelated working-tree files.

Jump to

Keyboard shortcuts

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