emit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package emit holds the render-emission helpers shared by the Kustomization and ResourceSet controllers: both parse a rendered doc set and land the children in the store through the identical two-pass strategy, so the logic lives here exactly once rather than being copied per controller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLeafReconcilable

func IsLeafReconcilable(obj manifest.BaseManifest) bool

IsLeafReconcilable reports whether an emitted object should be held for pass 2. Kustomization + HelmRelease have controllers that fire substituteFrom / chartRef lookups against the store the instant their AddObject event arrives; emitting them after all "data" kinds guarantees those lookups succeed. A ResourceSet is NOT a leaf — it is pass-1 data, emitted before the leaves so any KS/HR it itself produces (re-emitted in turn through this helper) lands behind its own data.

func ShouldDispatchAsObject

func ShouldDispatchAsObject(obj manifest.BaseManifest) bool

ShouldDispatchAsObject reports whether a render-emitted Flux resource needs to fire EventObjectAdded so its own controller picks it up. The pattern is: parent Kustomization renders → emits a child Flux resource (e.g. another Kustomization with parent patches applied, a HelmRelease, an OCIRepository fanned out from a kustomize component, a ResourceSet) → that child's controller must reconcile the patched version, not the statically-loaded one.

ResourceSet is included so a render-emitted RS expands through the DAG like any other reconcilable child. ResourceSetInputProvider is included so a render-emitted RSIP fires EventObjectAdded to WAKE any RS parked on it (or selector-matching RS at the drain fixpoint) — but it is pure data: the scheduler's dagSchedulable excludes it, so the arrival event registers no runnable node, exactly like a ConfigMap.

Types

type Child

type Child struct {
	Obj manifest.BaseManifest
	Doc map[string]any
}

Child is one parsed render-emission: the typed object and the source doc it was parsed from. Children returns these in doc order so a caller can post-process them (e.g. the ResourceSet controller routes RawObject children to its output sink) without re-parsing.

func Children

func Children(c *base.Controller, wipeSecrets bool, id manifest.NamedResource, docs []map[string]any, publish bool) []Child

Children parses the rendered docs and lands them in the store using a two-pass emission strategy:

  • Pass 1 — non-leaf "data" kinds (ConfigMap, Secret, sources, ResourceSet, RSIP, etc.) go into the store first. Sources go through AddObject because they have their own status to track; ConfigMap/Secret/RSIP have no controller (or no schedulable node), so AddObject's event dispatch only wakes waiters. Either way they're in the store before pass 2 fires.

  • Pass 2 — leaf reconcilables (Kustomization, HelmRelease). Their substituteFrom / chartRef lookups now see the data from pass 1.

Without the two passes, AddObject for a reconcilable kind fires its controller on a separate goroutine immediately, racing the parent's "data first" emission. Within each pass the controller renders docs in kustomize's emission order; passes themselves are ordered so the data backing a reconcile always arrives first.

Parse errors on inline resources are debug-logged and skipped — they may be raw Kubernetes manifests flate doesn't track. SOPS-encrypted secrets are debug-noted; ParseSecret wipes their values to the PLACEHOLDER token the same way --wipe-secrets does for cleartext.

publish gates the two event-firing store writes (AddObject for pass-1 reconcilables, AddObjects for pass-2 leaves). The fresh-render path passes true. The fingerprint-dedup replay passes FALSE: the children were already published byte-identically by the render that set the cached artifact, so re-AddObject-ing them would only re-fire EventObjectAdded and re-submit a coalesced re-reconcile of an already- settled child — churn that transiently flips a Ready parent back to Pending and, if a transient quiescence drain lands in that window, makes a dependent's depwait give up ("parent ... not ready"). The provenance (ReportRendered) and keep-set (KeepEmitted) side-effects the replay exists for are idempotent and event-free, so they still run on both paths; only the redundant republish is skipped.

Returns the parsed children in doc order (build directives and parse failures excluded), so a caller can post-process them without re-parsing — the ResourceSet controller routes the RawObject children to its output sink.

Jump to

Keyboard shortcuts

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