Skip to content

feat(utils): add typed cel evaluation#1616

Merged
abhijith-darshan merged 1 commit intomainfrom
feat/cel_typed_eval
Nov 19, 2025
Merged

feat(utils): add typed cel evaluation#1616
abhijith-darshan merged 1 commit intomainfrom
feat/cel_typed_eval

Conversation

@abhijith-darshan
Copy link
Copy Markdown
Contributor

@abhijith-darshan abhijith-darshan commented Nov 19, 2025

Description

Typed CEL Evaluation

For #1426 we need the value of CEL that is evaluated to be type safe

Current CEL will evaluate it into any, which might result into undesired helm values.

Consider the scenario where a plugin has the following ingress hosts -

apiVersion: greenhouse.sap/v1alpha1
kind: Plugin
metadata:
  name: plugin-a
  namespace: demo
spec:
...
  optionValues:
...
    - name: ingress.hosts
      value:
        - ingress-a.example.com
        - ingress-plugin-a.example.com
...

plugin-b needs to extract the hosts from plugin-a

apiVersion: greenhouse.sap/v1alpha1
kind: Plugin
metadata:
  name: plugin-b
  namespace: demo
spec:
...
  optionValues:
...
    - name: ingress.hosts
      valueRef:
          apiVersion: greenhouse.sap/v1alpha1
          kind: Plugin
          name: plugin-a
          expression: "<CEL-EXPR>"
...

the expression - object.spec.optionValues.filter(o, o.name == 'ingress.hosts')[0].value[0] returns the first element in the array.

the expression - object.spec.optionValues.filter(o, o.name == 'ingress.hosts')[0].value returns the array as is.

typed evaluation usage - value, err := cel.EvaluateTyped[[]string](expr, object)

The first expression will return error as the evaluation is a string and not an []string

The second expression will succeed as the evaluated value is indeed an []string

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

validating type evaluation result

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Signed-off-by: abhijith-darshan <abhijith.ravindra@sap.com>
@abhijith-darshan abhijith-darshan marked this pull request as ready for review November 19, 2025 01:13
@abhijith-darshan abhijith-darshan requested a review from a team as a code owner November 19, 2025 01:13
Copy link
Copy Markdown
Contributor

@uwe-mayer uwe-mayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like :)

@abhijith-darshan abhijith-darshan merged commit eb09f99 into main Nov 19, 2025
26 checks passed
@abhijith-darshan abhijith-darshan deleted the feat/cel_typed_eval branch November 19, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants