Documentation
¶
Overview ¶
Package kustomize wraps sigs.k8s.io/kustomize/api so the rest of flate never invokes the `kustomize` CLI. It provides:
- Render: return unstamped output from disk inputs through Flux's secure FS, or immutable source artifacts through their authoritative fs.FS. Generated files use one private overlay; artifact labels need not exist on disk.
- Prepare: the standard pre-render dance (Clone + expand postBuild.substituteFrom + authored inline values) for embedders rendering a single Kustomization. Symmetric to helm.Prepare for HelmReleases, minus a values cache; the substituteFrom path has no YAML parse to memoize; see Prepare's docstring.
- Substitute: envsubst-style "${VAR}" / "${VAR:=default}" used for Flux post-build substitutions.
Concurrency. Each Render call builds against its own private overlay, so no two renders share mutable state and there is no per-tree build lock. krusty's package-global state (the openapi schema registry, builtin plugin/transformer factories) is still not goroutine-safe, so the process-wide internal/engine/kustomize/krusty.BuildMutex serializes EVERY krusty invocation flate runs, including the helm post-renderer's krusty.Run in internal/engine/helm. fluxcd/pkg/kustomize guards its own Build for the same reason; every flate-owned krusty entrypoint MUST hold that same mutex.
Render persists unstamped output with its input read-set snapshot and validates that snapshot against the source view before reusing a frame.
Index ¶
- func GeneratorHashSeparator(name string) int
- func Prepare(ks *manifest.Kustomization, inputs []values.Result) (*manifest.Kustomization, error)
- func Render(ctx context.Context, cache *TreeCache, req RenderRequest, ...) ([]manifest.DocOccurrence, *manifest.RenderReceipt, error)
- func RenderInputs(receipt *manifest.RenderReceipt) map[string]bool
- func SourceInput(reads sourceReader, ks *manifest.Kustomization) (*store.SourceArtifact, error)
- func Substitute(data []byte, vars map[string]string, strict bool) ([]byte, error)
- type EntryEvidence
- type EntryInput
- type EntryOccurrence
- type GitBaseFetcher
- type GitBaseRequest
- type LocalInputs
- type Preparation
- type RenderRequest
- type RenderRequestOptions
- type ShapeOptions
- type Shaping
- type TreeCache
- func (c *TreeCache) ApplicationReceipt(ctx context.Context, request RenderRequest, evidence EntryEvidence, ...) (EntryEvidence, error)
- func (*TreeCache) EntryValid(ctx context.Context, evidence EntryEvidence, st *store.Store) bool
- func (c *TreeCache) PreviousEntry(ctx context.Context, req RenderRequest) EntryEvidence
- func (c *TreeCache) PreviousRender(ctx context.Context, req RenderRequest) ([]manifest.DocOccurrence, *manifest.RenderReceipt, bool)
- func (c *TreeCache) RecordEntry(ctx context.Context, receipt *manifest.RenderReceipt, reads *store.ReadSet) error
- func (*TreeCache) RenderHistory(owner manifest.NamedResource, receipt *manifest.RenderReceipt, content any) (iter.Seq2[manifest.NamedResource, manifest.DiscoveryRecord], bool)
- func (c *TreeCache) SetGitBaseFetcher(fn GitBaseFetcher)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratorHashSeparator ¶ added in v0.8.1
GeneratorHashSeparator returns -1 when a name cannot have a Kustomize generator hash.
func Prepare ¶
func Prepare( ks *manifest.Kustomization, inputs []values.Result, ) (*manifest.Kustomization, error)
Prepare clones ks and resolves referenced and inline substitutions.
func Render ¶
func Render( ctx context.Context, cache *TreeCache, req RenderRequest, retry sourcecache.RetryConfig, ) ([]manifest.DocOccurrence, *manifest.RenderReceipt, error)
Render returns unstamped renderer documents from an admitted source and a private overlay. Generated files never mutate the source. Cancellation is checked around the upstream build, which does not accept a context.
func RenderInputs ¶
func RenderInputs(receipt *manifest.RenderReceipt) map[string]bool
RenderInputs returns source-relative observed paths and whether each read excludes descendants.
func SourceInput ¶
func SourceInput(reads sourceReader, ks *manifest.Kustomization) (*store.SourceArtifact, error)
SourceInput permits an omitted source only when a path identifies the local tree.
Types ¶
type EntryEvidence ¶
type EntryEvidence struct {
GeneratedEntry bool `json:"GeneratedEntry"`
Producer manifest.NamedResource `json:"Producer"`
Application map[string]any `json:"Application"`
Root manifest.NamedResource `json:"Root"`
Owner manifest.NamedResource `json:"Owner"`
Records iter.Seq2[manifest.NamedResource, manifest.DiscoveryRecord] `json:"Records"`
Receipt *manifest.RenderReceipt `json:"Receipt"`
Inputs []EntryInput `json:"Inputs"`
Renders []*manifest.RenderReceipt `json:"Renders"`
}
EntryEvidence retains the accepted producer inventory that qualified an entry application.
type EntryInput ¶
type EntryInput struct {
Resource manifest.NamedResource `json:"Resource"`
Content string `json:"Content"`
Binding store.ArtifactInput `json:"Binding"`
Artifact *store.SourceArtifact `json:"-"`
Data manifest.Data `json:"-"`
}
EntryInput binds one resolved qualification input to owner-derived content.
type EntryOccurrence ¶ added in v0.8.1
EntryOccurrence identifies the declaration that an entry receipt qualifies.
type GitBaseFetcher ¶
type GitBaseFetcher func(context.Context, GitBaseRequest, cache.RetryConfig) (*store.SourceArtifact, error)
GitBaseFetcher acquires an immutable repository view for private render mounts.
type GitBaseRequest ¶
type GitBaseRequest struct {
Work manifest.WorkScope `json:"-"`
URL string `json:"URL"`
Ref string `json:"Ref"`
MaxAge time.Duration `json:"MaxAge"`
Timeout time.Duration `json:"Timeout"`
Submodules bool `json:"Submodules"`
}
GitBaseRequest carries effective Git policy and the referencing Flux interval.
type LocalInputs ¶ added in v0.8.1
type LocalInputs struct {
Files, Roots []string
Complete bool
// contains filtered or unexported fields
}
LocalInputs borrows one accepted source and the effective builder declaration.
func ObserveLocalInputs ¶ added in v0.8.1
func ObserveLocalInputs(ctx context.Context, req *RenderRequest) *LocalInputs
ObserveLocalInputs uses the local walk without acquiring or rewriting remote inputs.
func (*LocalInputs) Captures ¶ added in v0.8.1
func (p *LocalInputs) Captures(spec *manifest.Kustomization, source *store.SourceArtifact) bool
Captures binds selection evidence to the declaration and accepted source.
type Preparation ¶
type Preparation struct {
// contains filtered or unexported fields
}
Preparation MUST remain owned by one logical render consumer until transfer or retirement.
func (*Preparation) EntryDocumentMembership ¶ added in v0.8.1
func (p *Preparation) EntryDocumentMembership( ctx context.Context, receipt *manifest.RenderReceipt, project func([]string) []bool, ) map[int]bool
EntryDocumentMembership ties raw output ordinals to physical contributors in the same full build.
func (*Preparation) Matches ¶
func (p *Preparation) Matches(cache *TreeCache, request *RenderRequest) bool
Matches MUST NOT grant publication authority or validate current source bytes.
type RenderRequest ¶
type RenderRequest struct {
Preparation *Preparation `json:"-"`
EntryOccurrences []EntryOccurrence `json:"-"`
LocalInputs *LocalInputs `json:"-"`
// Work borrows stage counters from this render execution.
Work *manifest.RenderWork `json:"-"`
// HeldSlot is TreeCache's borrowed service when this render holds its slot.
// Standalone callers leave it nil.
HeldSlot *task.Service `json:"HeldSlot"`
// Source.FS supplies content; nil Source or FS is unavailable.
// Empty Source.Content denotes mutable content validated on every cache hit.
Source *store.SourceArtifact `json:"Source"`
// Label mounts source content in kyaml; empty uses Source.LocalPath.
Label string `json:"Label"`
// SubPath selects the source directory to build.
SubPath string `json:"SubPath"`
// Spec is the prepared Flux Kustomization; nil builds without a Flux owner.
Spec *manifest.Kustomization `json:"Spec"`
UncertainSubstitutionInputs bool `json:"UncertainSubstitutionInputs"`
UnreadableSubstitutions map[string]manifest.Reference `json:"-"`
// StrictSubstitutions binds undefined-variable handling to accepted history.
StrictSubstitutions bool `json:"StrictSubstitutions"`
// SkipKinds binds the effective emitted-kind policy to accepted history.
SkipKinds []string `json:"SkipKinds"`
}
RenderRequest carries the authoritative source and its mount label. Label is metadata and need not name an existing host path.
func NewRenderRequest ¶ added in v0.8.1
func NewRenderRequest( ks *manifest.Kustomization, inputs []values.Result, options *RenderRequestOptions, ) (RenderRequest, error)
NewRenderRequest MUST retain unreadable names from the authored spec before expanding substitutions.
type RenderRequestOptions ¶ added in v0.8.1
type RenderRequestOptions struct {
Source *store.SourceArtifact
SourceReads sourceReader
HeldSlot *task.Service
SkipKinds []string
StrictSubstitutions bool
TrackUnreadable bool
}
RenderRequestOptions uses SourceReads only when the caller has no selected Source.
type ShapeOptions ¶
type ShapeOptions struct {
Strict bool
Work *manifest.WorkRecord
// Originals receives the immutable hash inputs keyed by render stream ordinal.
Originals *map[int]map[string]any
}
ShapeOptions supplies substitution policy and its physical work counter.
type Shaping ¶
type Shaping struct {
// contains filtered or unexported fields
}
Shaping owns private documents and temporary YAML for one render attempt.
func PrepareShape ¶
func PrepareShape(request *RenderRequest, docs []manifest.DocOccurrence) *Shaping
PrepareShape MUST retain raw identity separately from sanitized application content. The caller applies producer metadata before preparing the shape.
func (*Shaping) Apply ¶
func (p *Shaping) Apply(_ context.Context, options ShapeOptions) error
Apply MUST retain every document failure while returning the first substitution error.
type TreeCache ¶
type TreeCache struct {
// contains filtered or unexported fields
}
TreeCache borrows backing storage and HTTP inputs for one run's render state. Callers MUST join renders before releasing borrowed dependencies.
func NewTreeCache ¶
func NewTreeCache(owner *cache.Cache, remoteInputs *source.HTTPInputs, tasks *task.Service) *TreeCache
NewTreeCache borrows the nonnil storage owner, HTTP inputs and task service.
func (*TreeCache) ApplicationReceipt ¶
func (c *TreeCache) ApplicationReceipt( ctx context.Context, request RenderRequest, evidence EntryEvidence, files []string, ) (EntryEvidence, error)
ApplicationReceipt captures complete local and resolved entry qualification inputs.
func (*TreeCache) EntryValid ¶
EntryValid qualifies provisional evidence against current resolved input content.
func (*TreeCache) PreviousEntry ¶
func (c *TreeCache) PreviousEntry(ctx context.Context, req RenderRequest) EntryEvidence
PreviousEntry MUST treat persisted evidence as provisional until current inputs qualify it.
func (*TreeCache) PreviousRender ¶
func (c *TreeCache) PreviousRender( ctx context.Context, req RenderRequest, ) ([]manifest.DocOccurrence, *manifest.RenderReceipt, bool)
PreviousRender returns validated raw output without rendering or acquiring remote inputs.
func (*TreeCache) RecordEntry ¶
func (c *TreeCache) RecordEntry(ctx context.Context, receipt *manifest.RenderReceipt, reads *store.ReadSet) error
RecordEntry MUST publish only complete evidence with current captured inputs.
func (*TreeCache) RenderHistory ¶
func (*TreeCache) RenderHistory( owner manifest.NamedResource, receipt *manifest.RenderReceipt, content any, ) (iter.Seq2[manifest.NamedResource, manifest.DiscoveryRecord], bool)
RenderHistory returns complete accepted inventory matching the current final inputs.
func (*TreeCache) SetGitBaseFetcher ¶
func (c *TreeCache) SetGitBaseFetcher(fn GitBaseFetcher)
SetGitBaseFetcher wires the git-clone capability used to resolve remote git bases referenced from a kustomization's resources:. The orchestrator calls this once at construction; library/test embedders may leave it unset.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package krusty coordinates access to krusty's process-global schema and plugins.
|
Package krusty coordinates access to krusty's process-global schema and plugins. |
|
Package kustomizeinput classifies Kustomize's direct file and configuration inputs.
|
Package kustomizeinput classifies Kustomize's direct file and configuration inputs. |
|
Package patch applies Flux patches to an already constructed document set.
|
Package patch applies Flux patches to an already constructed document set. |