Skip to main content
Version: v1.0.0-rc.1 (pre-release)

Context Variables

This reference documents all context variables available in Workflow, ComponentType, and Trait templates.

Workflow Variables​

The following variables are available in Workflow and ClusterWorkflow runTemplate and resources templates.

metadata​

Platform-computed metadata for workflow execution.

FieldTypeDescription
metadata.workflowRunNamestringName of the WorkflowRun CR
metadata.namespaceNamestringNamespace name of the WorkflowRun
metadata.namespacestringEnforced workflow plane namespace (e.g., workflows-default)
metadata.labelsmapWorkflowRun labels (e.g., openchoreo.dev/component, openchoreo.dev/project)

Usage:

metadata:
name: ${metadata.workflowRunName}
namespace: ${metadata.namespace}
spec:
arguments:
parameters:
- name: component-name
value: ${metadata.labels['openchoreo.dev/component']}
- name: project-name
value: ${metadata.labels['openchoreo.dev/project']}

parameters​

Developer-provided values from WorkflowRun.spec.workflow.parameters, with schema defaults from the Workflow's openAPIV3Schema applied.

# Access parameters defined in the Workflow schema
- name: git-repo
value: ${parameters.repository.url}
- name: branch
value: ${parameters.repository.revision.branch}

externalRefs​

Resolved external CR specs, keyed by the id declared in the Workflow's externalRefs. Only present when the Workflow declares external references. See ExternalRef.

# Access resolved SecretReference spec
template:
type: ${externalRefs['git-secret-reference'].spec.template.type}

# Iterate over secret data
data: |
${externalRefs['git-secret-reference'].spec.data.map(secret, {
"secretKey": secret.secretKey,
"remoteRef": {
"key": secret.remoteRef.key,
"property": has(secret.remoteRef.property) && secret.remoteRef.property != "" ? secret.remoteRef.property : oc_omit()
}
})}

ComponentType Variables​

The following variables are available in ComponentType resource templates.

metadata​

Platform-computed metadata for resource generation.

FieldTypeDescription
metadata.namestringBase name for generated resources (e.g., my-service-dev-a1b2c3d4)
metadata.namespacestringTarget namespace for resources
metadata.componentNamespacestringTarget namespace of the component
metadata.componentNamestringName of the component
metadata.componentUIDstringUnique identifier of the component
metadata.projectNamestringName of the project
metadata.projectUIDstringUnique identifier of the project
metadata.environmentNamestringName of the environment (e.g., development, production)
metadata.environmentUIDstringUnique identifier of the environment
metadata.dataPlaneNamestringName of the data plane
metadata.dataPlaneUIDstringUnique identifier of the data plane
metadata.labelsmapCommon labels to add to all resources
metadata.annotationsmapCommon annotations to add to all resources
metadata.podSelectorsmapPlatform-injected selectors for pod identity

Usage:

metadata:
name: ${metadata.name}
namespace: ${metadata.namespace}
labels: ${metadata.labels}
spec:
selector:
matchLabels: ${metadata.podSelectors}

parameters​

Component parameters from Component.spec.parameters with schema defaults applied. Use for static configuration that doesn't change across environments.

# Access parameters defined in schema.parameters
replicas: ${parameters.replicas}
port: ${parameters.port}

# Nested parameters
database:
host: ${parameters.database.host}
port: ${parameters.database.port}

environmentConfigs​

Environment-specific configuration from ReleaseBinding.spec.componentTypeEnvironmentConfigs, pruned to the ComponentType's environmentConfigs schema with defaults applied. Use for values that vary per environment (resources, replicas, etc.).

# Access environment-specific values
replicas: ${environmentConfigs.replicas}
resources:
limits:
cpu: ${environmentConfigs.resources.cpu}
memory: ${environmentConfigs.resources.memory}

workload​

Workload specification from the Workload resource.

FieldTypeDescription
workload.containerobjectContainer configuration
workload.container.imagestringContainer image
workload.container.command[]stringContainer command
workload.container.args[]stringContainer arguments
workload.endpointsmap[string]objectNetwork endpoints keyed by endpoint name
workload.endpoints[name].typestringEndpoint protocol (HTTP, REST, gRPC, GraphQL, Websocket, TCP, UDP)
workload.endpoints[name].portint32Port number
workload.endpoints[name].basePathstringBase path prefix (optional, default "/")
workload.endpoints[name].visibility[]stringVisibility scopes: "project", "external", "internal"
workload.endpoints[name].schemaobjectOptional API schema definition

Usage:

containers:
- name: main
image: ${workload.container.image}
command: ${workload.container.command}
args: ${workload.container.args}

# Iterate over endpoints with external visibility
- id: httproute-external
forEach: '${workload.endpoints.transformList(name, ep, ("external" in ep.visibility && ep.type in ["HTTP", "REST", "GraphQL", "Websocket"]) ? [name] : []).flatten()}'
var: endpoint
template:
# ...
spec:
backendRefs:
- name: ${metadata.componentName}
port: ${workload.endpoints[endpoint].port}

configurations​

Configuration and secret references extracted from the workload container.

FieldTypeDescription
configurations.configs.envs[]objectEnvironment variable configs (each has name, value)
configurations.configs.files[]objectFile configs (each has name, mountPath, value)
configurations.secrets.envs[]objectSecret env vars (each has name, value, remoteRef)
configurations.secrets.files[]objectSecret files (each has name, mountPath, remoteRef)

The remoteRef object contains: key, property (optional), version (optional).

Usage:

# Access config envs
env: |
${configurations.configs.envs.map(e, {"name": e.name, "value": e.value})}

# Check if there are config files
includeWhen: ${has(configurations.configs.files) && configurations.configs.files.size() > 0}

See Configuration Helpers for helper functions that simplify working with configurations.

dataplane​

Data plane configuration.

FieldTypeDescription
dataplane.secretStorestringName of the ClusterSecretStore for external secrets
dataplane.publicVirtualHoststringPublic virtual host for external access

Usage:

# ExternalSecret configuration
spec:
secretStoreRef:
name: ${dataplane.secretStore}
kind: ClusterSecretStore

gateway​

Ingress gateway configuration for routing traffic to components.

FieldTypeDescription
gateway.ingress.external.namestringName of the external ingress Gateway resource
gateway.ingress.external.namespacestringNamespace of the external ingress Gateway resource
gateway.ingress.external.httpobjectHTTP listener config (optional; has .host)
gateway.ingress.external.httpsobjectHTTPS listener config (optional; has .host)
gateway.ingress.internal.namestringName of the internal ingress Gateway resource
gateway.ingress.internal.namespacestringNamespace of the internal ingress Gateway resource
gateway.ingress.internal.httpobjectHTTP listener config for internal gateway (optional; has .host)
gateway.ingress.internal.httpsobjectHTTPS listener config for internal gateway (optional; has .host)

Usage:

# HTTPRoute targeting the external gateway
parentRefs:
- name: ${gateway.ingress.external.name}
namespace: ${gateway.ingress.external.namespace}

# Build hostnames from available HTTP/HTTPS listeners
hostnames: |
${[gateway.ingress.external.?http, gateway.ingress.external.?https]
.filter(g, g.hasValue()).map(g, g.value().host).distinct()
.map(h, oc_dns_label(endpoint, metadata.componentName, metadata.environmentName, metadata.componentNamespace) + "." + h)}

Trait Variables​

Traits have access to all the same variables as ComponentTypes, plus trait-specific variables.

trait​

Trait-specific metadata.

FieldTypeDescription
trait.namestringName of the trait (e.g., persistent-volume)
trait.instanceNamestringUnique instance name within the component (e.g., data-storage)

Usage:

# Use trait instance name for resource naming
metadata:
name: ${metadata.name}-${trait.instanceName}

# Use trait name in labels
labels:
trait: ${trait.name}
instance: ${trait.instanceName}

parameters (Traits)​

Trait instance parameters from Component.spec.traits[].parameters with schema defaults applied.

# Access trait-specific parameters
volumeMounts:
- name: ${parameters.volumeName}
mountPath: ${parameters.mountPath}

environmentConfigs (Traits)​

Environment-specific configuration from ReleaseBinding.spec.traitEnvironmentConfigs[instanceName], pruned to the Trait's environmentConfigs schema with defaults applied.

# Access environment-specific trait values
resources:
requests:
storage: ${environmentConfigs.size}
storageClassName: ${environmentConfigs.storageClass}

Variable Availability Summary​

VariableWorkflowComponentTypeTrait createsTrait patches
metadata.*YesYesYesYes
parametersYesYesYesYes
externalRefsYesNoNoNo
environmentConfigsNoYesYesYes
workload.container.*NoYesNoNo
workload.endpoints.*NoYesNoNo
configurations.*NoYesNoNo
dataplane.*NoYesYesYes
gateway.*NoYesYesYes
trait.*NoNoYesYes
resource (patch target)NoNoNoYes (in where)

Examples​

ComponentType Using All Variables​

apiVersion: openchoreo.dev/v1alpha1
kind: ComponentType
metadata:
name: web-service
spec:
workloadType: deployment
resources:
- id: deployment
template:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${metadata.name}
namespace: ${metadata.namespace}
labels: ${metadata.labels}
spec:
replicas: ${environmentConfigs.replicas}
selector:
matchLabels: ${metadata.podSelectors}
template:
metadata:
labels: ${metadata.podSelectors}
spec:
containers:
- name: main
image: ${workload.container.image}
ports:
- containerPort: ${parameters.port}
envFrom: ${configurations.toContainerEnvFrom()}

Trait Using Trait-Specific Variables​

apiVersion: openchoreo.dev/v1alpha1
kind: Trait
metadata:
name: persistent-volume
spec:
creates:
- template:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${metadata.name}-${trait.instanceName}
namespace: ${metadata.namespace}
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: ${environmentConfigs.storageClass}
resources:
requests:
storage: ${environmentConfigs.size}