change

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: 21 Imported by: 0

Documentation

Overview

Package change computes file-level differences between two filesystem trees and maps them onto the Flux resources they affect.

It is the core of flate's "changed-only" mode (--path-orig on any command): walk both trees in parallel, SHA-256 every regular file, emit the relative paths that differ. Callers then ask Filter whether a given resource — identified by the file it was loaded from — has changed.

The filter cascades through references: when a HelmRelease's file changed, its chart source (OCIRepository / HelmRepository / GitRepository) is also marked needed so the actual chart still gets downloaded. Likewise, a Kustomization's sourceRef is kept ready so downstream waits succeed. dependsOn is intentionally excluded: it's a reconcile-ordering signal, not a content dependency.

The cascade also runs in reverse: when the changed file IS a source resource, every HelmRelease/Kustomization that references it is kept so its render re-runs against the new source spec. This catches the centralized-source layout where an OCIRepository lives in its own Kustomization tree, separate from the HelmReleases that chartRef it — bumping the OCIRepository's tag must still re-render those consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparison added in v0.7.3

type Comparison struct{ Changed, Known bool }

Comparison grants a change verdict only when Known is true.

type DeclarationInputs added in v0.7.3

type DeclarationInputs struct {
	Stores   [2]*store.Store
	Prepared [2]map[manifest.NamedResource]store.Child
	Work     manifest.WorkScope
}

DeclarationInputs carries the completed source pair and its preparation authority.

type InputChange added in v0.7.3

type InputChange struct {
	File         string
	Declarations []string
	Productions  []manifest.Production
	Unbound      bool // Neither side supplies an admitted read of File.
}

InputChange records a changed input and its static discovery authority.

type Set

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

Set carries immutable bootstrap-path changes and qualified source evidence. Completed sets are immutable and safe to share; CollectInputs is construction-only.

func Detect

func Detect(ctx context.Context, before, after *store.SourceArtifact, work manifest.WorkScope) (*Set, error)

Detect compares admitted filesystems under each side's Flux ignore policy.

func NewSet

func NewSet(paths []string) *Set

NewSet constructs a path-only Set without Detect's one-sided input identities.

func Qualify added in v0.7.3

func Qualify(ctx context.Context, changes *Set, stores [2]*store.Store, work manifest.WorkScope) (*Set, error)

Qualify compares available admitted source pairs before reconciliation. Supplied changes retain their bootstrap coordinates and are never mutated.

func (*Set) CollectInputs added in v0.7.3

func (s *Set) CollectInputs(ctx context.Context, input fs.FS, name string, before bool) error

CollectInputs records a one-sided path and its declared content. Before identifies the baseline side; WithReaders resolves its exact read dependents. Call only while constructing an unpublished Set, never concurrently, and discard the set on error. Completed sets returned by Detect or baseline resolution MUST remain immutable.

func (*Set) Contains

func (s *Set) Contains(rel string) bool

Contains reports whether rel is in the change set. rel is expected to be filepath.ToSlash-normalized.

func (*Set) DeclarationChanged added in v0.7.3

func (s *Set) DeclarationChanged(
	side manifest.TreeSide,
	source, id manifest.NamedResource,
	document map[string]any,
) Comparison

DeclarationChanged compares complete declared content and the current prepared document. A nil document grants no authority over preparation or additional build inputs.

func (*Set) ForSource added in v0.7.3

func (s *Set) ForSource(source manifest.NamedResource) (*Set, [2]*store.SourceArtifact, [2]manifest.BaseManifest)

ForSource returns source-relative changes, exact admitted artifacts and their source declarations.

func (*Set) Inputs added in v0.7.3

Inputs yields qualified one-sided inputs matching a name, or all inputs for an empty name.

func (*Set) Len

func (s *Set) Len() int

Len reports how many files differ.

func (*Set) OppositeDeclaration added in v0.7.3

func (s *Set) OppositeDeclaration(
	side manifest.TreeSide,
	source, id manifest.NamedResource,
	current manifest.BaseManifest,
) manifest.BaseManifest

OppositeDeclaration returns the opposite declaration while the local identity and declaration apply. Source artifact applicability MUST be checked by the caller against ForSource first.

func (*Set) OutputChanged added in v0.7.3

func (s *Set) OutputChanged(
	side manifest.TreeSide,
	source manifest.NamedResource,
	ref manifest.Reference,
	current manifest.BaseManifest,
) Comparison

OutputChanged reads a frozen verdict only while the same local declaration and reference apply. Source artifact applicability MUST be checked by the caller against ForSource first.

func (*Set) Paths

func (s *Set) Paths() []string

Paths returns the changed files as a sorted slice.

func (*Set) Sources added in v0.7.3

func (s *Set) Sources() iter.Seq[manifest.NamedResource]

Sources yields the source identities carrying immutable comparison evidence.

func (*Set) WithDeclarations added in v0.7.3

func (s *Set) WithDeclarations(
	ctx context.Context,
	input DeclarationInputs,
) (*Set, error)

WithDeclarations freezes observed authoritative declaration and reference comparisons before dispatch. Only completed producer output is prepared comparison authority; raw producer-owned input is excluded. Missing preparation is unknown; the returned set retains no Store or captured read set.

func (*Set) WithReaders added in v0.7.3

func (s *Set) WithReaders(
	ctx context.Context,
	indexes [2]*manifest.DiscoveryIndex,
	inputs [2]map[manifest.NamedResource]inputprojection.Projection,
	scope manifest.WorkScope,
) (*Set, error)

WithReaders derives affected inputs from raw facts and current discovery observations. The receiver and both discovery indexes remain immutable.

Jump to

Keyboard shortcuts

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