Documentation
¶
Index ¶
- func BuildStructuralSchemas(input *SchemaInput) (*SchemaBundle, *SchemaBundle, error)
- func CELExtensions() []cel.EnvOption
- func CELValidationExtensions() []cel.EnvOption
- func FunctionReturnTypes() []reflect.Type
- func MergeWorkloadOverrides(baseWorkload *openchoreov1alpha1.Workload, ...) *openchoreov1alpha1.Workload
- func ResolveEmbeddedTraitBindings(engine *template.Engine, embeddedTrait v1alpha1.ComponentTypeTrait, ...) (resolvedParams map[string]any, resolvedEnvConfigs map[string]any, err error)
- type ComponentContext
- type ComponentContextInput
- type ConfigFileListEntry
- type ConfigMapVolume
- type ConfigurationItems
- type ConnectionEnvVar
- type ConnectionItem
- type ConnectionsContextData
- type ConnectionsData
- type ContainerConfigurations
- type ContainerData
- type DataPlaneData
- type EmbeddedTraitContextInput
- type EndpointData
- type EnvConfiguration
- type EnvFromEntry
- type EnvironmentData
- type EnvsByContainerEntry
- type FileConfiguration
- type GatewayData
- type GatewayEndpointData
- type GatewayListenerData
- type GatewayNetworkData
- type MetadataContext
- type NameRef
- type ObservabilityPlaneRefData
- type RemoteRefData
- type SchemaBundle
- type SchemaInput
- type SecretFileListEntry
- type SecretVolume
- type ServicePortEntry
- type TraitContext
- type TraitContextInput
- type TraitMetadata
- type VolumeEntry
- type VolumeMountEntry
- type WorkloadData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildStructuralSchemas ¶ added in v0.7.0
func BuildStructuralSchemas(input *SchemaInput) (*SchemaBundle, *SchemaBundle, error)
BuildStructuralSchemas builds separate structural schemas for parameters and environmentConfigs.
Returns (parametersBundle, envConfigsBundle, error). Either bundle's schemas can be nil if not provided.
func CELExtensions ¶ added in v0.9.0
CELExtensions returns CEL environment options for configuration helpers used by the runtime template engine. Function overloads return list(dyn) and include runtime bindings.
func CELValidationExtensions ¶ added in v1.0.0
CELValidationExtensions returns CEL environment options for the validation environment. Unlike CELExtensions(), function overloads declare typed return types instead of dyn, enabling the type checker to validate field access on forEach loop variables. No binding functions are registered since validation never evaluates expressions.
func FunctionReturnTypes ¶ added in v1.0.0
FunctionReturnTypes returns the unique Go types used as return types by CEL helper functions. Used by the validation environment to register DeclTypes for field-access validation.
func MergeWorkloadOverrides ¶ added in v0.6.0
func MergeWorkloadOverrides(baseWorkload *openchoreov1alpha1.Workload, overrides *openchoreov1alpha1.WorkloadOverrideTemplateSpec) *openchoreov1alpha1.Workload
MergeWorkloadOverrides merges workload overrides into the base workload. Supports merging container env and file configurations.
func ResolveEmbeddedTraitBindings ¶ added in v0.14.0
func ResolveEmbeddedTraitBindings( engine *template.Engine, embeddedTrait v1alpha1.ComponentTypeTrait, componentContextMap map[string]any, ) (resolvedParams map[string]any, resolvedEnvConfigs map[string]any, err error)
ResolveEmbeddedTraitBindings resolves CEL expressions in an embedded trait's parameter and environmentConfigs bindings against the component context.
Values in the embedded trait bindings can be:
- Concrete values (locked by PE): passed through as-is
- CEL expressions like "${parameters.storage.mountPath}": evaluated against the component context
Returns the resolved parameters and environmentConfigs as maps.
Types ¶
type ComponentContext ¶ added in v0.6.0
type ComponentContext struct {
// Metadata provides structured naming and labeling information.
// Accessed via ${metadata.name}, ${metadata.namespace}, ${metadata.componentName}, etc.
Metadata MetadataContext `json:"metadata"`
// DataPlane provides data plane configuration.
// Accessed via ${dataplane.secretStore}, ${dataplane.gateway.ingress.external.https.host}, etc.
DataPlane DataPlaneData `json:"dataplane"`
// Environment provides environment-specific gateway configuration.
// Accessed via ${environment.gateway.ingress.external.https.host}, etc.
// Falls back to DataPlane gateway values if Environment.Gateway is not configured.
Environment EnvironmentData `json:"environment"`
// Gateway provides the effective gateway configuration for this deployment.
// Uses environment gateway if configured, falls back to DataPlane gateway.
// Accessed via ${gateway.ingress.external.https.host}, etc.
Gateway *GatewayData `json:"gateway,omitempty"`
// Parameters from Component.Spec.Parameters, pruned to ComponentType.Spec.Parameters schema.
// Accessed via ${parameters.*}
Parameters map[string]any `json:"parameters"`
// EnvironmentConfigs from ReleaseBinding.Spec.ComponentTypeEnvironmentConfigs, pruned to ComponentType.Spec.EnvironmentConfigs schema.
// Accessed via ${environmentConfigs.*}
EnvironmentConfigs map[string]any `json:"environmentConfigs"`
// Workload contains workload specification (container, endpoints, connections).
// Accessed via ${workload.container}, ${workload.endpoints}, etc.
Workload WorkloadData `json:"workload"`
// Configurations are extracted configuration items from workload.
// Contains configs and secrets for the single container.
// Accessed via ${configurations.configs.envs}, ${configurations.secrets.files}, etc.
Configurations ContainerConfigurations `json:"configurations"`
// Dependencies contains dependency metadata and merged env vars for templates.
// Accessed via ${dependencies.items} and ${dependencies.envVars}.
Dependencies ConnectionsContextData `json:"dependencies"`
}
ComponentContext represents the evaluated context for rendering component resources. This is the output of BuildComponentContext and is used by the template engine.
func BuildComponentContext ¶
func BuildComponentContext(input *ComponentContextInput) (*ComponentContext, error)
BuildComponentContext builds a CEL evaluation context for rendering component resources.
The context includes:
- parameters: From Component.Spec.Parameters (pruned to schema.parameters) - access via ${parameters.*}
- environmentConfigs: From ReleaseBinding.Spec.ComponentTypeEnvironmentConfigs (pruned to schema.environmentConfigs) - access via ${environmentConfigs.*}
- workload: Workload specification (image, resources, etc.) - access via ${workload.*}
- metadata: Structured naming and labeling information - access via ${metadata.*}
- dataplane: Data plane configuration - access via ${dataplane.*}
- configurations: Extracted configuration items from workload - access via ${configurations.*}
Schema defaults are applied to both parameters and environmentConfigs sections.
func (*ComponentContext) ToMap ¶ added in v0.6.0
func (c *ComponentContext) ToMap() map[string]any
ToMap converts the ComponentContext to map[string]any for CEL evaluation. All fields including configurations are converted to nested maps via JSON marshaling. This allows consistent CEL access without requiring ext.NativeTypes() registration.
type ComponentContextInput ¶
type ComponentContextInput struct {
// Component is the component definition.
Component *v1alpha1.Component `validate:"required"`
// ComponentType is the type definition for the component.
ComponentType *v1alpha1.ComponentType `validate:"required"`
// ReleaseBinding contains release reference and environment-specific overrides.
ReleaseBinding *v1alpha1.ReleaseBinding
// DataPlane contains the data plane configuration.
// Required - controller must provide this.
DataPlane *v1alpha1.DataPlane `validate:"required"`
// Environment contains the environment configuration.
// Required - controller must provide this.
Environment *v1alpha1.Environment `validate:"required"`
// WorkloadData is the pre-computed workload data (containers, endpoints).
// Should be computed once by the caller using ExtractWorkloadData and shared.
WorkloadData WorkloadData
// Configurations is the pre-computed configurations from workload.
// Should be computed once by the caller using ExtractConfigurationsFromWorkload
// and shared across ComponentContext and all TraitContexts.
Configurations ContainerConfigurations
// Metadata provides structured naming and labeling information.
// Required - controller must provide this.
Metadata MetadataContext `validate:"required"`
// Dependencies contains pre-computed dependency environment variables.
// Optional - if not provided, dependencies context will be empty.
Dependencies ConnectionsData
// DefaultNotificationChannel is the default notification channel name for the environment.
// Optional - if not provided, the defaultNotificationChannel field in EnvironmentData will be empty.
DefaultNotificationChannel string
}
ComponentContextInput contains all inputs needed to build a component rendering context.
type ConfigFileListEntry ¶ added in v1.0.0
type ConfigFileListEntry struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
Value string `json:"value"`
ResourceName string `json:"resourceName"`
RemoteRef *RemoteRefData `json:"remoteRef,omitempty"`
}
ConfigFileListEntry represents an element returned by configurations.toConfigFileList().
type ConfigMapVolume ¶ added in v1.0.0
type ConfigMapVolume struct {
Name string `json:"name"`
}
ConfigMapVolume represents a configMap volume source.
type ConfigurationItems ¶ added in v0.6.0
type ConfigurationItems struct {
Envs []EnvConfiguration `json:"envs"`
Files []FileConfiguration `json:"files"`
}
ConfigurationItems contains environment and file configurations.
type ConnectionEnvVar ¶ added in v0.17.0
ConnectionEnvVar is a pre-computed env var name/value pair for a resolved connection.
type ConnectionItem ¶ added in v0.17.0
type ConnectionItem struct {
Namespace string `json:"namespace"`
Project string `json:"project"`
Component string `json:"component"`
Endpoint string `json:"endpoint"`
Visibility string `json:"visibility"`
EnvVars []ConnectionEnvVar `json:"envVars"`
}
ConnectionItem represents a single connection with its target metadata and resolved env vars.
type ConnectionsContextData ¶ added in v0.17.0
type ConnectionsContextData struct {
Items []ConnectionItem `json:"items"`
EnvVars []ConnectionEnvVar `json:"envVars"`
}
ConnectionsContextData is the template context representation of connections. It contains both the per-item details and a merged flat list of all env vars. Accessed via ${connections.items} and ${connections.envVars}.
type ConnectionsData ¶ added in v0.17.0
type ConnectionsData struct {
Items []ConnectionItem `json:"items"`
}
ConnectionsData contains the list of connections with their metadata and per-item env vars. This is the input type used in RenderInput and context inputs.
type ContainerConfigurations ¶ added in v0.6.0
type ContainerConfigurations struct {
Configs ConfigurationItems `json:"configs"`
Secrets ConfigurationItems `json:"secrets"`
}
ContainerConfigurations contains configs and secrets for a container.
func ExtractConfigurationsFromWorkload ¶ added in v0.11.0
func ExtractConfigurationsFromWorkload(secretReferences map[string]*v1alpha1.SecretReference, workload *v1alpha1.Workload) ContainerConfigurations
ExtractConfigurationsFromWorkload extracts env and file configurations from the workload container and organizes them with configs vs secrets separation. Returns the container's configs and secrets. Always initializes empty slices for envs and files to ensure they're never nil. Example structure: {"configs": {"envs": [...], "files": [...]}, "secrets": {"envs": [...], "files": [...]}}
type ContainerData ¶ added in v0.6.0
type ContainerData struct {
Image string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
}
ContainerData contains container information.
type DataPlaneData ¶ added in v0.6.0
type DataPlaneData struct {
SecretStore string `json:"secretStore,omitempty"`
Gateway *GatewayData `json:"gateway,omitempty"`
ObservabilityPlaneRef *ObservabilityPlaneRefData `json:"observabilityPlaneRef,omitempty"`
}
DataPlaneData provides data plane configuration in templates.
type EmbeddedTraitContextInput ¶ added in v0.14.0
type EmbeddedTraitContextInput struct {
// Trait is the trait definition.
Trait *v1alpha1.Trait `validate:"required"`
// InstanceName is the unique instance name for this embedded trait.
InstanceName string `validate:"required"`
// ResolvedParameters contains the CEL-resolved parameters from the embedded binding.
// These are already concrete values (CEL expressions have been evaluated).
ResolvedParameters map[string]any
// ResolvedEnvironmentConfigs contains the CEL-resolved environmentConfig defaults from the embedded binding.
ResolvedEnvironmentConfigs map[string]any
// Component is the component this trait is being applied to.
Component *v1alpha1.Component `validate:"required"`
// WorkloadData is the pre-computed workload data.
WorkloadData WorkloadData
// Configurations is the pre-computed configurations from workload.
Configurations ContainerConfigurations
// Dependencies contains pre-computed dependency environment variables.
Dependencies ConnectionsData
// Metadata provides structured naming and labeling information.
Metadata MetadataContext `validate:"required"`
// SchemaCache is an optional cache for schema bundles.
SchemaCache map[string]*SchemaBundle
// DataPlane contains the data plane configuration.
DataPlane *v1alpha1.DataPlane `validate:"required"`
// Environment contains the environment configuration.
Environment *v1alpha1.Environment `validate:"required"`
// DefaultNotificationChannel is the default notification channel name for the environment.
// Optional - if not provided, the defaultNotificationChannel field in EnvironmentData will be empty.
DefaultNotificationChannel string
}
EmbeddedTraitContextInput contains all inputs needed to build a context for an embedded trait.
type EndpointData ¶ added in v0.11.0
type EndpointData struct {
DisplayName string `json:"displayName,omitempty"`
Port int32 `json:"port"`
TargetPort int32 `json:"targetPort"`
Type string `json:"type"`
BasePath string `json:"basePath,omitempty"`
Visibility []string `json:"visibility"`
}
EndpointData contains endpoint information.
type EnvConfiguration ¶ added in v0.6.0
type EnvConfiguration struct {
Name string `json:"name"`
Value string `json:"value,omitempty"`
RemoteRef *RemoteRefData `json:"remoteRef,omitempty"`
}
EnvConfiguration represents an environment variable configuration.
type EnvFromEntry ¶ added in v1.0.0
type EnvFromEntry struct {
ConfigMapRef *NameRef `json:"configMapRef,omitempty"`
SecretRef *NameRef `json:"secretRef,omitempty"`
}
EnvFromEntry represents an element returned by configurations.toContainerEnvFrom().
type EnvironmentData ¶ added in v0.15.0
type EnvironmentData struct {
Gateway *GatewayData `json:"gateway,omitempty"`
DefaultNotificationChannel string `json:"defaultNotificationChannel,omitempty"`
}
EnvironmentData provides environment-specific gateway configuration in templates. If the environment does not have gateway configuration, values fallback to DataPlane gateway.
type EnvsByContainerEntry ¶ added in v1.0.0
type EnvsByContainerEntry struct {
ResourceName string `json:"resourceName"`
Envs []EnvConfiguration `json:"envs"`
}
EnvsByContainerEntry represents an element returned by configurations.toConfigEnvsByContainer() or configurations.toSecretEnvsByContainer().
type FileConfiguration ¶ added in v0.6.0
type FileConfiguration struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
Value string `json:"value,omitempty"`
RemoteRef *RemoteRefData `json:"remoteRef,omitempty"`
}
FileConfiguration represents a file configuration.
type GatewayData ¶ added in v0.17.0
type GatewayData struct {
Ingress *GatewayNetworkData `json:"ingress,omitempty"`
Egress *GatewayNetworkData `json:"egress,omitempty"`
}
GatewayData provides gateway configuration in templates.
type GatewayEndpointData ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 ¶ added in v0.17.0
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 {
// ComponentName is the name of the component.
// Example: "my-service"
ComponentName string `json:"componentName" validate:"required"`
// ComponentUID is the unique identifier of the component.
// Example: "a1b2c3d4-5678-90ab-cdef-1234567890ab"
ComponentUID string `json:"componentUID" validate:"required"`
// ProjectName is the name of the project.
// Example: "my-project"
ProjectName string `json:"projectName" validate:"required"`
// ProjectUID is the unique identifier of the project.
// Example: "b2c3d4e5-6789-01bc-def0-234567890abc"
ProjectUID string `json:"projectUID" validate:"required"`
// DataPlaneName is the name of the data plane.
// Example: "my-dataplane"
DataPlaneName string `json:"dataPlaneName" validate:"required"`
// DataPlaneUID is the unique identifier of the data plane.
// Example: "c3d4e5f6-7890-12cd-ef01-34567890abcd"
DataPlaneUID string `json:"dataPlaneUID" validate:"required"`
// EnvironmentName is the name of the environment.
// Example: "production"
EnvironmentName string `json:"environmentName" validate:"required"`
// EnvironmentUID is the unique identifier of the environment.
// Example: "d4e5f6g7-8901-23de-f012-4567890abcde"
EnvironmentUID string `json:"environmentUID" validate:"required"`
// Name is the base name to use for generated resources.
// Example: "my-service-dev-a1b2c3d4"
Name string `json:"name" validate:"required"`
// Namespace is the target namespace for the resources.
// Example: "dp-acme-corp-payment-dev-x1y2z3w4"
Namespace string `json:"namespace" validate:"required"`
// ComponentNamespace is the namespace on which the component is created.
// Example: "cp-acme-corp"
ComponentNamespace string `json:"componentNamespace" validate:"required"`
// Labels are common labels to add to all resources.
// Example: {"openchoreo.dev/component": "my-service", ...}
Labels map[string]string `json:"labels" validate:"required"`
// Annotations are common annotations to add to all resources.
Annotations map[string]string `json:"annotations" validate:"required"`
// PodSelectors are platform-injected selectors for pod identity.
// Used in Deployment selectors, Service selectors, etc.
// Example: {
// "openchoreo.dev/namespace": "dp-acme-corp-payment-dev-x1y2z3w4",
// "openchoreo.dev/project": "acme-corp",
// "openchoreo.dev/component": "payment",
// "openchoreo.dev/environment": "dev",
// "openchoreo.dev/component-uid": "abc123",
// "openchoreo.dev/environment-uid": "dev",
// "openchoreo.dev/project-uid": "xyz789",
// }
PodSelectors map[string]string `json:"podSelectors" validate:"required,min=1"`
}
MetadataContext provides structured metadata for resource generation. This is computed by the controller and passed to the renderer.
type NameRef ¶ added in v1.0.0
type NameRef struct {
Name string `json:"name"`
}
NameRef is a reference containing a name field.
type ObservabilityPlaneRefData ¶ added in v0.15.0
type ObservabilityPlaneRefData struct {
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
}
ObservabilityPlaneRefData provides observability plane reference in templates.
type RemoteRefData ¶ added in v0.6.0
type RemoteRefData struct {
Key string `json:"key"`
Property string `json:"property,omitempty"`
Version string `json:"version,omitempty"`
}
RemoteRefData contains remote reference data for secrets.
type SchemaBundle ¶ added in v0.9.0
type SchemaBundle struct {
Structural *apiextschema.Structural
JSONSchema *extv1.JSONSchemaProps
}
SchemaBundle holds both structural and JSON schemas for validation workflows. The structural schema is used for pruning and defaulting, while the JSON schema is used for validation.
type SchemaInput ¶
type SchemaInput struct {
// ParametersSchema is the parameters schema section.
ParametersSchema *v1alpha1.SchemaSection
// EnvironmentConfigsSchema is the environmentConfigs schema section.
EnvironmentConfigsSchema *v1alpha1.SchemaSection
}
SchemaInput contains schema information for building structural and JSON schemas.
type SecretFileListEntry ¶ added in v1.0.0
type SecretFileListEntry struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
ResourceName string `json:"resourceName"`
RemoteRef *RemoteRefData `json:"remoteRef,omitempty"`
}
SecretFileListEntry represents an element returned by configurations.toSecretFileList().
type SecretVolume ¶ added in v1.0.0
type SecretVolume struct {
SecretName string `json:"secretName"`
}
SecretVolume represents a secret volume source.
type ServicePortEntry ¶ added in v1.0.0
type ServicePortEntry struct {
Name string `json:"name"`
Port int64 `json:"port"`
TargetPort int64 `json:"targetPort"`
Protocol string `json:"protocol"`
}
ServicePortEntry represents an element returned by workload.toServicePorts().
type TraitContext ¶ added in v0.7.0
type TraitContext struct {
// Metadata provides structured naming and labeling information.
// Accessed via ${metadata.name}, ${metadata.namespace}, ${metadata.componentName}, etc.
Metadata MetadataContext `json:"metadata"`
// Trait contains trait-specific metadata.
// Accessed via ${trait.name}, ${trait.instanceName}
Trait TraitMetadata `json:"trait"`
// Parameters from TraitInstance.Parameters, pruned to Trait.Spec.Parameters schema.
// Accessed via ${parameters.*}
Parameters map[string]any `json:"parameters"`
// EnvironmentConfigs from ReleaseBinding.Spec.TraitEnvironmentConfigs[instanceName], pruned to Trait.Spec.EnvironmentConfigs schema.
// Accessed via ${environmentConfigs.*}
EnvironmentConfigs map[string]any `json:"environmentConfigs"`
// DataPlane provides data plane configuration.
// Accessed via ${dataplane.secretStore}, ${dataplane.gateway.ingress.external.https.host}, etc.
DataPlane DataPlaneData `json:"dataplane"`
// Environment provides environment-specific gateway configuration.
// Accessed via ${environment.gateway.ingress.external.https.host}, etc.
// Falls back to DataPlane gateway values if Environment.Gateway is not configured.
Environment EnvironmentData `json:"environment"`
// Gateway provides the effective gateway configuration for this deployment.
// Uses environment gateway if configured, falls back to DataPlane gateway.
// Accessed via ${gateway.ingress.external.https.host}, etc.
Gateway *GatewayData `json:"gateway,omitempty"`
// Workload contains workload specification (container, endpoints).
// Accessed via ${workload.container}, ${workload.endpoints}
Workload WorkloadData `json:"workload"`
// Configurations are extracted configuration items from workload.
// Contains configs and secrets for the single container.
// Accessed via ${configurations.configs.envs}, ${configurations.secrets.files}, etc.
Configurations ContainerConfigurations `json:"configurations"`
// Dependencies contains dependency metadata and merged env vars for templates.
// Accessed via ${dependencies.items} and ${dependencies.envVars}.
Dependencies ConnectionsContextData `json:"dependencies"`
}
TraitContext represents the evaluated context for rendering trait resources. This is the output of BuildTraitContext and is used by the template engine.
func BuildEmbeddedTraitContext ¶ added in v0.14.0
func BuildEmbeddedTraitContext(input *EmbeddedTraitContextInput) (*TraitContext, error)
BuildEmbeddedTraitContext builds a CEL evaluation context for rendering an embedded trait's resources.
Unlike BuildTraitContext, this function:
- Uses pre-resolved parameters (already evaluated from CEL bindings)
func BuildTraitContext ¶
func BuildTraitContext(input *TraitContextInput) (*TraitContext, error)
BuildTraitContext builds a CEL evaluation context for rendering trait resources.
The context includes:
- parameters: From TraitInstance.Parameters (pruned to Trait.Spec.Parameters schema) - access via ${parameters.*}
- environmentConfigs: From ReleaseBinding.Spec.TraitEnvironmentConfigs[instanceName] (pruned to Trait.Spec.EnvironmentConfigs schema) - access via ${environmentConfigs.*}
- trait: Trait metadata (name, instanceName) - access via ${trait.*}
- metadata: Structured naming and labeling information - access via ${metadata.*}
Schema defaults are applied to both parameters and environmentConfigs sections.
Note: TraitEnvironmentConfigs is keyed by instanceName (not traitName), as instanceNames must be unique across all traits in a component.
func (*TraitContext) ToMap ¶ added in v0.7.0
func (t *TraitContext) ToMap() map[string]any
ToMap converts the TraitContext to map[string]any for CEL evaluation.
type TraitContextInput ¶
type TraitContextInput struct {
// Trait is the trait definition.
Trait *v1alpha1.Trait `validate:"required"`
// Instance contains the specific instance configuration.
Instance v1alpha1.ComponentTrait `validate:"required"`
// Component is the component this trait is being applied to.
Component *v1alpha1.Component `validate:"required"`
// ReleaseBinding contains release reference and environment-specific overrides.
// Can be nil if no overrides are needed.
ReleaseBinding *v1alpha1.ReleaseBinding
// WorkloadData is the pre-computed workload data (containers, endpoints).
// Should be computed once by the caller using ExtractWorkloadData and shared.
WorkloadData WorkloadData
// Configurations is the pre-computed configurations from workload.
// Should be computed once by the caller using ExtractConfigurationsFromWorkload
// and shared across ComponentContext and all TraitContexts.
Configurations ContainerConfigurations
// Metadata provides structured naming and labeling information.
// Required - controller must provide this.
Metadata MetadataContext `validate:"required"`
// Dependencies contains pre-computed dependency environment variables.
// Optional - if not provided, dependencies context will be empty.
Dependencies ConnectionsData
// SchemaCache is an optional cache for schema bundles, keyed by trait kind+name with suffix.
// Used to avoid rebuilding schemas for the same trait used multiple times.
// BuildTraitContext will check this cache before building and populate it after.
// Cache keys use format "{kind}:{traitName}:parameters" and "{kind}:{traitName}:environmentConfigs".
SchemaCache map[string]*SchemaBundle
// DataPlane contains the data plane configuration.
// Required - controller must provide this.
DataPlane *v1alpha1.DataPlane `validate:"required"`
// Environment contains the environment configuration.
// Required - controller must provide this.
Environment *v1alpha1.Environment `validate:"required"`
// DefaultNotificationChannel is the default notification channel name for the environment.
// Optional - if not provided, the defaultNotificationChannel field in EnvironmentData will be empty.
DefaultNotificationChannel string
}
TraitContextInput contains all inputs needed to build a trait rendering context.
type TraitMetadata ¶ added in v0.7.0
type TraitMetadata struct {
// Name is the name of the trait.
// Example: "storage"
Name string `json:"name"`
// InstanceName is the unique instance name within the component.
// Example: "my-storage"
InstanceName string `json:"instanceName"`
}
TraitMetadata contains trait-specific metadata.
type VolumeEntry ¶ added in v1.0.0
type VolumeEntry struct {
Name string `json:"name"`
ConfigMap *ConfigMapVolume `json:"configMap,omitempty"`
Secret *SecretVolume `json:"secret,omitempty"`
}
VolumeEntry represents an element returned by configurations.toVolumes().
type VolumeMountEntry ¶ added in v1.0.0
type VolumeMountEntry struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
SubPath string `json:"subPath"`
}
VolumeMountEntry represents an element returned by configurations.toContainerVolumeMounts().
type WorkloadData ¶ added in v0.6.0
type WorkloadData struct {
Container ContainerData `json:"container"`
Endpoints map[string]EndpointData `json:"endpoints"`
}
WorkloadData contains workload information for templates.
func ExtractWorkloadData ¶ added in v0.11.0
func ExtractWorkloadData(workload *v1alpha1.Workload) WorkloadData
ExtractWorkloadData extracts relevant workload information for the rendering context. This function is exported so callers can pre-compute workload data once and share it across multiple context builds (ComponentContext and TraitContexts).