loader

package
v0.8.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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

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

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

Prepare MUST preserve the sanitized outcome even when typed admission fails.

func Promote

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

func ValidateDeclarations(children []store.Declaration) error

ValidateDeclarations requires authored identity against all invocation definitions.

Types

type BuiltInput

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

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

Catalog borrows immutable loader facts until its owner calls Close.

func (*Catalog) CatalogObject

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

CatalogObject borrows the declaration with its effective identity.

func (*Catalog) Close

func (c *Catalog) Close()

Close releases borrowed catalog storage and is safe to repeat.

func (*Catalog) RootEvidence

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

RootEvidence with completeOwners false requires the caller to complete support with its preparation inventory.

func (*Catalog) SourceExternal

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

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

AdmissionCandidate borrows the immutable declaration prepared during construction.

func (*Loader) Admit

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

Admit MUST finish construction before its caller publishes admission.

func (*Loader) AdmitDeclarations

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

AdmitDeclarations retains pathless reference evidence before repository discovery.

func (*Loader) BuiltChildren

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

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

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

func (*Loader) Close

func (l *Loader) Close()

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

func (*Loader) CompleteDeclarations

func (l *Loader) CompleteDeclarations(
	ctx context.Context,
	demand selection.DeclarationDemand,
) (*manifest.DiscoveryIndex, error)

CompleteDeclarations MUST finish before readers consume the immutable index.

func (*Loader) DeclarationContents

func (*Loader) DeclarationContents() func(map[string]any) store.DeclarationContent

DeclarationContents MUST be confined to one serial admission preparation. Independent preparations never share mutable memoization state.

func (*Loader) DetachCatalog

func (l *Loader) DetachCatalog() *Catalog

DetachCatalog keeps borrowed catalog facts alive beyond Loader.Close.

func (*Loader) EntryFailure

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

EntryFailure MUST defer admission until selection consumes its iterator.

func (*Loader) EntryFrontier

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

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

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

FinalizeIndex MUST freeze source-qualified graph contributions before reconciliation.

func (*Loader) IndexedObject

IndexedObject returns the retained declaration under its contextual identity.

func (*Loader) IsFileIndexed

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

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

func (*Loader) Kustomizations

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

Occurrence borrows exact declaration coordinates and immutable parsed facts.

func (*Loader) OccurrenceClaims

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

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

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

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

func (*Loader) Occurrences

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

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

Packages snapshots resource graph inputs already traversed by Load.

func (*Loader) ParsedInputs

func (l *Loader) ParsedInputs() *ParsedInputs

ParsedInputs snapshots parsed bodies without retaining entry admission state.

func (*Loader) PathObjects

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

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

func (*Loader) PersistInputs

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

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

func (*Loader) PreparedObject

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

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

ProducerFacts reuses immutable projections across concurrent preparations.

func (*Loader) PromoteOrphans

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

PromoteOrphans MUST run after index finalization.

func (*Loader) PromotionDocuments

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

PromotionDocuments returns the immutable indexed batch used to promote id.

func (*Loader) ReferenceFacts

ReferenceFacts resolves data against the current discovery index before publication.

func (*Loader) References

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

References MUST consume immutable declaration evidence synchronously.

func (*Loader) RegisterBuilt

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

RegisterBuilt MUST receive sanitized immutable build output and retire support in publication order.

func (*Loader) ResolveRoot

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

func (l *Loader) Retire()

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

func (*Loader) RootEvidence

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

RootEvidence with completeOwners false requires the caller to complete support with its preparation inventory.

func (*Loader) SelectionIndex

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

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

func (*Loader) SourceFacts

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

SourceFacts MUST capture current reads before reusing source evidence.

func (*Loader) Sources

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

func (l *Loader) SweepPreparations()

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

type PackageEvidence

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

PackageEvidence retains package provenance and shared root admission.

type ParsedInputs

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

ParsedInputs retains immutable parsed content from exact admitted source views.

func (*ParsedInputs) Matches

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

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

type PromoteOptions

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

PromoteOptions binds acquisition to an exact source and captured generation.

type SourceLocation

type SourceLocation struct {
	Path             string
	Pinned, External bool
}

SourceLocation binds a source path to its pin and ownership.

func SourceView

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