Documentation
¶
Overview ¶
Package projectpipeline renders the inlined (Cluster)ProjectType.spec.resources templates for a single ProjectReleaseBinding. It depends on internal/template (the shared CEL engine), internal/schema (OpenAPI v3 helpers), and the exported control-flow helpers from internal/pipeline/component/renderer (ShouldInclude, EvalForEach, EvaluateValidationRules); it does not import controller-runtime.
The pipeline exposes one method:
- Render walks ProjectTypeSpec.Resources[] and returns the rendered entries. ForEach templates contribute one entry per iteration with ID suffixed by the iteration index. CEL context exposes ${metadata.*} (including namespace), ${parameters.*}, ${environmentConfigs.*}, ${dataplane.*}, ${environment.*}, and the effective ${gateway.*}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseContext ¶
type BaseContext struct {
Metadata MetadataContext `json:"metadata"`
Parameters map[string]any `json:"parameters"`
EnvironmentConfigs map[string]any `json:"environmentConfigs"`
DataPlane DataPlaneContext `json:"dataplane"`
Environment EnvironmentContext `json:"environment"`
// Gateway is the effective gateway (Environment.Gateway, which itself is
// env-or-dp merged) exposed at the top level for terseness:
// ${gateway.egress.external.https.host} is identical to
// ${environment.gateway.egress.external.https.host}.
//
// Templates that may evaluate against a missing gateway must guard via
// has(environment.gateway) — has(gateway) is invalid CEL because the
// top-level alias is omitted from the marshaled map when nil.
Gateway *GatewayData `json:"gateway,omitempty"`
}
BaseContext is the top-level CEL surface produced by buildBaseContext and fed into the template engine.
type DataPlaneContext ¶
type DataPlaneContext struct {
// SecretStore is the name of the ESO ClusterSecretStore configured on the
// DataPlane. ProjectTypes emitting a shared-cell ExternalSecret reference
// this.
SecretStore string `json:"secretStore,omitempty"`
// Gateway is the raw DataPlane-level gateway configuration. Nil when the
// DataPlane has no gateway configured. The effective gateway used by most
// templates is the merged Environment-or-DataPlane value exposed at the
// top-level ${gateway.*} and on ${environment.gateway.*}.
Gateway *GatewayData `json:"gateway,omitempty"`
// ObservabilityPlaneRef is the observability plane reference for
// ProjectTypes that emit observability-plane-side resources. Optional; nil
// when the DataPlane has no observability plane configured. Templates that
// reference ${dataplane.observabilityPlaneRef.*} must guard with
// has(dataplane.observabilityPlaneRef).
ObservabilityPlaneRef *ObservabilityPlaneRefContext `json:"observabilityPlaneRef,omitempty"`
}
DataPlaneContext is the dataplane surface exposed to CEL templates as ${dataplane.*}. Optional fields use omitempty so templates can guard with has(...) — mirrors the resource pipeline's contract.
func BuildDataPlaneContext ¶
func BuildDataPlaneContext(dataPlane *v1alpha1.DataPlane) DataPlaneContext
BuildDataPlaneContext extracts the dataplane CEL surface from a v1alpha1.DataPlane CR. Pure function, no controller-runtime imports. Returns a zero-valued context when dataPlane is nil so callers don't have to guard.
type EnvironmentContext ¶
type EnvironmentContext struct {
Gateway *GatewayData `json:"gateway,omitempty"`
}
EnvironmentContext is the per-environment surface exposed to CEL templates as ${environment.*}. Gateway carries the merged effective gateway: environment-level overrides take precedence, falling back to dataplane-level values at each leaf. Mirrors the resource pipeline's EnvironmentContext.
func BuildEnvironmentContext ¶
func BuildEnvironmentContext(env *v1alpha1.Environment, dataPlane *v1alpha1.DataPlane) EnvironmentContext
BuildEnvironmentContext extracts the per-environment CEL surface, merging environment-level gateway overrides with dataplane-level fallbacks at each leaf. Mirrors the component pipeline's mergeGatewayData semantics: ingress and egress merge independently; within each, external and internal endpoints fall back independently. Returns a zero-valued context (no gateway) when both inputs are nil.
type GatewayData ¶
type GatewayData struct {
Ingress *GatewayNetworkData `json:"ingress,omitempty"`
Egress *GatewayNetworkData `json:"egress,omitempty"`
}
GatewayData provides gateway configuration in templates.
type GatewayEndpointData ¶
type GatewayEndpointData struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
HTTP *GatewayListenerData `json:"http,omitempty"`
HTTPS *GatewayListenerData `json:"https,omitempty"`
TLS *GatewayListenerData `json:"tls,omitempty"`
}
GatewayEndpointData provides endpoint data for a gateway in templates.
type GatewayListenerData ¶
type GatewayListenerData struct {
ListenerName string `json:"listenerName,omitempty"`
Port int32 `json:"port,omitempty"`
Host string `json:"host,omitempty"`
}
GatewayListenerData provides listener data for a gateway in templates.
type GatewayNetworkData ¶
type GatewayNetworkData struct {
External *GatewayEndpointData `json:"external,omitempty"`
Internal *GatewayEndpointData `json:"internal,omitempty"`
}
GatewayNetworkData provides traffic gateway data for ingress/egress in templates.
type MetadataContext ¶
type MetadataContext struct {
// Namespace is the platform-computed dp-{ns}-{project}-{env}-{hash}
// data-plane namespace for this (project, environment). The mandated
// Namespace template references it as metadata.name = ${metadata.namespace};
// other templates set their own metadata.namespace from it.
Namespace string `json:"namespace"`
// ProjectNamespace is the control-plane namespace where the
// ProjectReleaseBinding lives.
ProjectNamespace string `json:"projectNamespace"`
ProjectName string `json:"projectName"`
ProjectUID string `json:"projectUID"`
EnvironmentName string `json:"environmentName"`
EnvironmentUID string `json:"environmentUID"`
DataPlaneName string `json:"dataPlaneName"`
DataPlaneUID string `json:"dataPlaneUID"`
// Labels are platform-injected standard labels. PE templates that
// propagate ${metadata.labels} get consistent labeling across every
// rendered DP-side object.
Labels map[string]string `json:"labels"`
// Annotations are propagated from the ProjectReleaseBinding CR.
Annotations map[string]string `json:"annotations"`
}
MetadataContext is the platform-injected metadata surface exposed to CEL templates as ${metadata.*}. The controller computes every field before calling the pipeline. JSON tags determine the CEL-facing field names when the context is marshaled via structToMap.
type ObservabilityPlaneRefContext ¶
ObservabilityPlaneRefContext is the {kind, name} reference exposed under ${dataplane.observabilityPlaneRef.*}.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline renders the inlined (Cluster)ProjectType.spec.resources templates for a single ProjectReleaseBinding. The instance holds a template.Engine whose CEL environment and program caches are reused across calls; consumers (binding controller, future CLI) instantiate one Pipeline and reuse it.
func NewPipeline ¶
func NewPipeline() *Pipeline
NewPipeline returns a Pipeline backed by a fresh template.Engine. The engine's CEL env and program caches accumulate across calls; reuse the Pipeline instance to keep them warm.
func (*Pipeline) Render ¶
func (p *Pipeline) Render(input *RenderInput) (*RenderOutput, error)
Render walks ProjectTypeSpec.Resources[] and returns one RenderedEntry per template that passes its IncludeWhen check. ForEach templates expand into one entry per iteration with the ID suffixed by index.
The CEL context built once per call exposes:
- ${metadata.*} (namespace, projectName/UID, environmentName/UID, ...)
- ${parameters.*} (Project.spec.parameters with schema defaults applied)
- ${environmentConfigs.*} (binding overrides with schema defaults applied)
- ${dataplane.*} (secretStore, gateway, observabilityPlaneRef)
- ${environment.*} (env-or-dataplane merged gateway)
- ${gateway.*} (top-level alias of the effective environment gateway)
ProjectTypeSpec.Validations are evaluated against the same context before rendering begins; any rule that returns false aborts the call.
type RenderInput ¶
type RenderInput struct {
// ProjectTypeSpec is the inlined (Cluster)ProjectType spec snapshot from
// the ProjectRelease (release.spec.projectType.spec). The pipeline reads
// Validations, Parameters (schema), EnvironmentConfigs (schema), and
// Resources from it. Required.
ProjectTypeSpec *v1alpha1.ProjectTypeSpec
// ProjectParameters is the snapshot of Project.spec.parameters from the
// ProjectRelease (release.spec.parameters). Validated against
// ProjectTypeSpec.Parameters and exposed to CEL as ${parameters.*}.
// Optional: nil yields an empty parameter map before schema defaults are
// applied.
ProjectParameters *runtime.RawExtension
// EnvironmentConfigs is the per-env override supplied via
// ProjectReleaseBinding.spec.environmentConfigs. Validated against
// ProjectTypeSpec.EnvironmentConfigs and exposed to CEL as
// ${environmentConfigs.*}. Optional.
EnvironmentConfigs *runtime.RawExtension
// Metadata is the controller-computed metadata surface exposed to CEL as
// ${metadata.*}. Must include Namespace; the mandated Namespace template
// renders against it as metadata.name = ${metadata.namespace}.
Metadata MetadataContext
// DataPlane is the controller-computed dataplane surface exposed to CEL
// as ${dataplane.*}. Built from the DataPlane the binding resolves via
// BuildDataPlaneContext.
DataPlane DataPlaneContext
// Environment is the controller-computed per-environment surface exposed
// to CEL as ${environment.*}. Gateway carries the merged effective
// gateway (environment-or-dataplane fallback at each leaf) for templates
// that emit cell egress NetworkPolicies / routing against the gateway.
Environment EnvironmentContext
}
RenderInput carries everything Render needs. The binding controller rehydrates ProjectTypeSpec and ProjectParameters from the immutable ProjectRelease snapshot and supplies EnvironmentConfigs from the binding.
type RenderOutput ¶
type RenderOutput struct {
// Entries are the rendered resources, one per
// ProjectTypeSpec.Resources[] that passed its IncludeWhen check, plus
// one extra entry per forEach iteration.
Entries []RenderedEntry
}
RenderOutput carries the rendered manifests in spec order. ForEach templates contribute one entry per iteration, with ID suffixed by the iteration index.
type RenderedEntry ¶
type RenderedEntry struct {
// ID identifies the rendered entry. For non-forEach templates it equals
// the source ResourceTemplate.ID verbatim; for forEach iterations it is
// suffixed with "-<index>" so the binding controller can correlate
// observed status back to a specific iteration.
ID string
// Object is the rendered Kubernetes resource as a map. CEL substitutions
// have been evaluated and omit-sentinel keys removed.
Object map[string]any
}
RenderedEntry is one rendered manifest. The controller marshals Object into runtime.RawExtension at its own boundary so the pipeline stays free of K8s runtime types in its public surface.