Skip to content

fix(cel): register kro's hash, IP, CIDR and semver CEL libraries - #129

Open
sarankumar1325 wants to merge 1 commit into
crossplane-contrib:mainfrom
sarankumar1325:fix-cel-hash-library
Open

sarankumar1325 wants to merge 1 commit into
crossplane-contrib:mainfrom
sarankumar1325:fix-cel-hash-library

Conversation

@sarankumar1325

Copy link
Copy Markdown

Description of your changes

function-kro pins kro v0.9.2 in go.mod. The vendored kro/cel package still has the v0.9.0 environment, though, so it is missing the CEL libraries upstream added after that. Any expression that uses hash.sha256, hash.fnv64a or hash.md5 fails at graph build with references unknown identifiers: [hash]. ip(), cidr() and semver() don't work either.

This PR:

  • copies pkg/cel/library/hash.go and hash_test.go from kro v0.9.2 into kro/cel/library/ without changes (they need no import-path fixes)
  • registers library.Hash(), k8scellib.IP(), k8scellib.CIDR() and k8scellib.SemverLib() in BaseDeclarations(). The declaration list now matches upstream v0.9.2 exactly, so environment.go drifts less from upstream.
  • adds ip, cidr and semver cases to TestDefaultEnvironment_KubernetesLibraries, and adds hash.fnv64a, hash.sha256 and hash.md5 to Test_CELEnvHasFunction. Both tests fail without the environment.go change.

Checked locally with go build ./..., go test ./... (all packages pass) and golangci-lint run ./kro/cel/... (0 issues).

Fixes #127

I have:

AI disclosure: I made this change with help from an AI assistant (Grok Bot). I reviewed the diff and ran the tests above.

function-kro pins kro v0.9.2, but the vendored CEL environment was copied
from v0.9.0 and never picked up the libraries upstream added since. Any
expression that uses hash.sha256/hash.fnv64a/hash.md5 failed at graph build
with "references unknown identifiers: [hash]", and ip(), cidr() and
semver() were also unavailable.

Vendor pkg/cel/library/hash.go and hash_test.go from kro v0.9.2 unchanged
and register library.Hash(), k8scellib.IP(), k8scellib.CIDR() and
k8scellib.SemverLib() in BaseDeclarations, so the list now matches
upstream v0.9.2. Add environment tests for the new functions.

Fixes crossplane-contrib#127

Assisted-by: Grok Bot
Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendored CEL environment omits kro's hash library (and IP/CIDR/Semver k8s libs)

1 participant