Documentation
¶
Overview ¶
Package manifestrenderer is the fleet's one typed source → manifest-dialect renderer — so a workload is declared ONCE as a typed Source and rendered, byte-stable, to a Helm chart, a kustomize overlay, and an OpenShift variant. This kills chart-vs-manifest drift: the three dialects can never disagree because they are projections of the same typed value.
Why ¶
Teams routinely maintain a Helm chart AND a hand-written kustomize tree AND an OpenShift manifest set for the same service. They drift — a replica bump lands in the chart but not the overlay, a security-context tweak lands in kustomize but not OpenShift. The cure is a single typed source of truth and pure, deterministic renderers.
Shape (Law 1, §3.5) ¶
src := manifestrenderer.New("api",
manifestrenderer.WithImage("ghcr.io/acme/api", "1.4.0"),
manifestrenderer.WithReplicas(3),
manifestrenderer.WithPort("http", 8080))
chart, err := src.RenderHelm() // map[path]bytes — a complete chart
overlay, err := src.RenderKustomize() // map[path]bytes — base + overlay
ocp, err := src.RenderOpenShift() // OpenShift-flavoured manifests
Every renderer is a pure function of the Source: same input → identical bytes, every time (deterministic key ordering, no maps iterated in render order, no timestamps). That byte-stability is the property that makes the rendered artifacts safe to commit and diff in CI.
Weight (Law 6) ¶
Pure standard library plus errors-go for typed, code-carrying errors. No YAML dependency: the deterministic emitter is internal so the rendered bytes are owned by this package, not by an upstream marshaller's formatting choices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvVar ¶
EnvVar is a literal environment variable. Secret-valued env is intentionally out of scope here — secret materialization is a separate concern.
type Files ¶
Files is a rendered artifact set: a path → bytes map. Use Files.Paths for a deterministically-ordered iteration so callers writing the set to disk (and diffing it in CI) get stable ordering.
type Option ¶
type Option func(*Source)
Option configures a Source during New. Options apply in order, so a later option of the same kind overrides an earlier one.
func WithServiceAccount ¶
WithServiceAccount sets the workload service account.
type Source ¶
type Source struct {
// Name is the workload name; it seeds resource names, labels, and the Helm
// chart name. Required.
Name string
// Namespace is the target namespace. Empty leaves it unset (rendered into
// the kustomize overlay / Helm release namespace by the deploy tool).
Namespace string
// Image is the container image repository (without the tag). Required.
Image string
// Tag is the container image tag. Defaults to "latest".
Tag string
// Replicas is the desired replica count. Defaults to 1.
Replicas int
// Ports are the named container ports, kept sorted by name for stable
// output.
Ports []Port
// Env are the environment variables, kept sorted by name for stable output.
Env []EnvVar
// Labels are extra labels merged onto the standard label set, kept sorted by
// key for stable output.
Labels map[string]string
// ServiceAccount is the workload's service account name. Empty uses the
// namespace default.
ServiceAccount string
}
Source is the one typed declaration of a workload. Every dialect renderer is a pure projection of this value, so the dialects can never drift from one another.
Construct a Source with New and functional options rather than building the struct literal directly; the constructor applies defaults and validates the invariants (notably a non-empty name and a non-empty image) in one place.
func New ¶
New builds and validates a Source. It returns a typed, code-carrying error (code "manifest_invalid") when a required field is missing.
func (*Source) RenderHelm ¶
RenderHelm renders the source as a complete, byte-stable Helm chart: a Chart.yaml, a values.yaml, and templated manifests under templates/. The templates render concrete manifests (no Go-template expansion) so the chart's rendered output equals the kustomize/OpenShift output object-for-object — that equality is the drift-killer.
func (*Source) RenderKustomize ¶
RenderKustomize renders the source as a kustomize base plus an overlay. The base holds the raw objects; the overlay holds a kustomization.yaml that references the base and pins the namespace/image tag — the canonical base+overlay split. Output is byte-stable.
func (*Source) RenderOpenShift ¶
RenderOpenShift renders the source as OpenShift-flavoured manifests: the same objects as the K8s base, minus the runAsNonRoot securityContext (the OpenShift SCC assigns the UID), plus a Route for the first port when one exists. Output is byte-stable.