Documentation
¶
Overview ¶
Package render takes a loaded package + Selection + Inputs and produces rendered Kubernetes manifests by:
- Synthesizing a top-level kustomization.yaml under out/compose/ that references the chosen base + Components and wires the ConfigHub transformers and validators as kustomize transformer / validator plugins.
- Resolving the package's Transformers + Validators against the Inputs (Go templates) and writing them to out/compose/{transformers,validators}.yaml as KRM function configs.
- Shelling out to `kustomize build --enable-exec --enable-alpha-plugins`, which invokes `installer transformer` (via a wrapper script in out/compose/) to run each function group in process.
- Splitting the resulting multi-doc YAML into per-resource files with deterministic naming, written to out/manifests/.
- Persisting the resolved FunctionChain alongside selection.yaml and inputs.yaml in out/spec/ so re-render is reproducible and the exact transforms applied are inspectable.
Index ¶
- func CleanRenderedOutput(outDir string) error
- func DefaultFetcher(ctx context.Context, ref, digest, destDir string) (string, error)
- func FormatValidatorFailures(failures []chainexec.ValidatorFailure) string
- func RunValidators(ctx context.Context, pkg *api.Package, sel *api.Selection, inputs *api.Inputs, ...) ([]chainexec.ValidatorFailure, error)
- type DepResult
- type DepsOptions
- type Fetcher
- type File
- type Options
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanRenderedOutput ¶
CleanRenderedOutput clears previously rendered output so a re-render starts from a clean slate — in particular so resources dropped by an upgrade don't linger as stale files (a plain Render overwrites produced files but never removes ones it didn't produce).
It deletes the rendered manifests in out/manifests/ but PRESERVES a Kptfile there, if present, so the directory stays a valid kpt base package across upgrades (its package identity and any consumer's upstream pointer survive). See docs/kpt-guide.md. out/secrets/ is removed wholesale.
func DefaultFetcher ¶
DefaultFetcher pulls a locked dependency via ipkg.Pull. The ref is digest-pinned (oci://...:tag@sha256:...) so the registry's response is verified against the lock. If destDir already contains a package, the fetch is skipped — the caller's cache hit.
func FormatValidatorFailures ¶
func FormatValidatorFailures(failures []chainexec.ValidatorFailure) string
FormatValidatorFailures re-exports chainexec.FormatValidatorFailures so callers that already import render don't have to add a second import.
func RunValidators ¶
func RunValidators(ctx context.Context, pkg *api.Package, sel *api.Selection, inputs *api.Inputs, facts *api.Facts, packageRoot string, data []byte) ([]chainexec.ValidatorFailure, error)
RunValidators is the public entry point used by `installer vet`. Resolves the package's spec.validators template against inputs + selection + facts and runs each group against data (the concatenated rendered manifests). packageRoot is the directory loadJSON/other template helpers anchor relative paths against. Returns a list of failures, or nil on full success.
Types ¶
type DepResult ¶
type DepResult struct {
Name string
OutDir string
Manifests []File
Secrets []File
PackageRoot string // where the dep's source tree was materialized
}
DepResult records the outcome of one dependency render.
func RenderDependencies ¶
func RenderDependencies(ctx context.Context, opts DepsOptions) ([]DepResult, error)
RenderDependencies renders each entry in opts.Lock into its own subtree under <WorkDir>/out/<dep-name>/. The lock's Selection and Inputs are used as wizard pre-answers; selection closure is run on top so the dep's own Requires/Conflicts/ValidForBases rules are honored.
Returns one DepResult per resolved dependency, in lock order.
type DepsOptions ¶
type DepsOptions struct {
// Lock is the resolved dependency tree, typically read from
// <work-dir>/out/spec/lock.yaml.
Lock *api.Lock
// ParentInputs carries the parent's namespace. Used as the default
// namespace for dependencies whose lock entry does not provide one.
ParentInputs *api.Inputs
// WorkDir is the parent's working directory. Vendor cache lives at
// <WorkDir>/out/vendor/<name>@<version>/, dep render outputs go to
// <WorkDir>/out/<dep-name>/.
WorkDir string
// Fetcher resolves a locked dep's ref+digest to a local package root.
// If nil, DefaultFetcher is used.
Fetcher Fetcher
// TransformerBinary is propagated to each per-dep Render call. Defaults
// to os.Executable() inside Render when empty.
TransformerBinary string
}
DepsOptions configures RenderDependencies.
type Fetcher ¶
Fetcher resolves a locked dependency to a local directory the renderer can load. Implementations are responsible for digest verification.
destDir is the parent-chosen cache slot for this dependency. The function returns the absolute path to the package root (containing installer.yaml).
type File ¶
type File struct {
// Filename is the recommended filename within out/manifests/ (or
// out/secrets/ when Sensitive).
Filename string
// Slug is the recommended ConfigHub Unit slug for upload.
Slug string
// Body is the YAML body of the resource.
Body []byte
// Kind / Name / Namespace / APIVersion are sniffed from the doc, used
// for the manifest index.
APIVersion string
Kind string
Name string
Namespace string
// Sensitive marks resources that must never be uploaded as Units.
// Currently set for any v1/Secret. Routed to out/secrets/ instead of
// out/manifests/ and skipped by `installer upload`.
Sensitive bool
}
File represents one rendered Kubernetes resource as it will be written to disk and uploaded as one ConfigHub Unit (unless Sensitive is true, in which case it is written to out/secrets/ and never uploaded).
type Options ¶
type Options struct {
Loaded *ipkg.Loaded
Selection *api.Selection
Inputs *api.Inputs
// Facts is the parsed facts.yaml. Nil when the package has no collector
// or the wizard has not been re-run after one was added.
Facts *api.Facts
// TransformerBinary is the absolute path baked into the
// out/compose/installer-transformer wrapper script. Defaults to
// os.Executable() — the binary currently running Render. Tests inject a
// freshly-built installer binary so the go test binary (which doesn't
// implement the `transformer` subcommand) isn't invoked by kustomize.
TransformerBinary string
}
Options controls Render. All fields are required except Facts and TransformerBinary.
type Result ¶
type Result struct {
// OutDir is the directory written to (out/manifests + out/secrets + out/spec
// + out/compose underneath).
OutDir string
// Manifests is the per-resource non-sensitive output, ordered by Slug.
Manifests []File
// Secrets is the per-resource sensitive output (Kubernetes Secrets),
// written to out/secrets/ and never uploaded as Units.
Secrets []File
// Chain is the resolved FunctionChain that was executed (also persisted
// to spec/ and to compose/chain.yaml).
Chain *api.FunctionChain
}
Result is what Render produces.
func Render ¶
Render reads the package + selection + inputs, drives kustomize (which invokes `installer transformer` as an exec plugin to apply the function chain and validators), and writes per-resource files plus the spec docs to outDir.
outDir is created if missing. Existing files in outDir/manifests are overwritten; files not produced by this render are NOT removed (callers who want a clean slate should remove manifests/ first). out/compose/ is always cleared and rewritten so the on-disk kustomization tree reflects the current render exactly.