Read function pipeline state
Compositions execute each function sequentially in the pipeline. Each function has two main tasks:
- Update the state of resources as they change
- Send the updated state data back to Crossplane.
Each function receives four key data points:
- Current state: The real-world status of the composite resource and related resources
- Target state: The desired status of resources as defined in your configuration
- Function input: The specific configuration settings for this function
- Pipeline context: Shared information passed through the function pipeline
This information is available to access a KCL embedded function.
Access function pipeline state
When using KCL embedded functions, these pieces of information are accessible using the built-in option()
function in KCL:
- Read the ObservedCompositeResource from
option("params").oxr
- Read the ObservedComposedResources from
option("params").ocds
- Read the DesiredCompositeResource from
option("params").dxr
- Read the DesiredComposedResources from
option("params").dcds
- Read the function pipeline’s context from
option("params").ctx
You can use these variables to do interesting things, such as extracting data from composed resources or write status to the composite resource.