Skip to content

KCL ocds (ObservedComposite detail context) is empty #164

@jeremywyx

Description

@jeremywyx

What happened?

When using function-kcl, it is common to reference the observed state of the composite resource or other context variables via option("params").ocds.

Current Behavior:
When running crossplane-diff, the ocds variable appears to be empty or unpopulated during the render phase. Consequently, any logic in the KCL function that relies on these variables results in null values in the rendered output. This generates false positives in the diff, showing fields changing from a valid value (live) to null (rendered).

Expected Behavior:
crossplane-diff should ideally mock or allow passing of the Observed Composite context so that KCL functions can render resources correctly with the expected variable values.

How can we reproduce it?

# In the KCL function
ocds = option("params").ocds
region = ocds["composite"]["spec"]["region"] # This evaluates to null/empty during diff

What environment did it happen in?

Crossplane version: 1.20
Kubernetes version : 1.32

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions