-
Notifications
You must be signed in to change notification settings - Fork 256
feat: Add CEL-based conditional function execution (#4388) #4391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
SurbhiAgarwal1
wants to merge
61
commits into
kptdev:main
from
SurbhiAgarwal1:feat/cel-conditional-execution
Closed
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
df657cf
feat: Add CEL-based conditional function execution
SurbhiAgarwal1 f868f34
fix: remove k8s.io/apiserver dependency from CEL evaluator
SurbhiAgarwal1 afd7eaa
refactor: move CELEnvironment to runneroptions, compile program per E…
SurbhiAgarwal1 95701b2
Potential fix for pull request finding
SurbhiAgarwal1 b421aa8
refactor: replace Go unit e2e test with proper fn-render testdata
SurbhiAgarwal1 7636e8c
fix: remove k8s.io/apiserver from go.mod, fix celeval_test.go imports
SurbhiAgarwal1 d6c85c6
fix: nil CELEnvironment in cmdeval test struct comparison
SurbhiAgarwal1 d73d928
fix: two e2e test failures in condition testdata
SurbhiAgarwal1 a15a358
fix: update condition testdata diff.patch with correct expected output
SurbhiAgarwal1 4157cd8
fix: correct e2e testdata and clarify k8s CEL library decision
SurbhiAgarwal1 24abdee
fix: update diff.patch with exact hashes from CI output
SurbhiAgarwal1 85a877f
feat: add k8s.io/apiserver CEL library extensions (IP, CIDR, Quantity…
SurbhiAgarwal1 836ab60
fix: correct SemVer function name to SemverLib in k8s CEL library
SurbhiAgarwal1 bc712d6
fix: increase reconcile-timeout from 2m to 5m in live-apply e2e tests
SurbhiAgarwal1 bc99a85
fix: address Copilot review comments
SurbhiAgarwal1 c6746cf
fix: address PR review feedback from mozesl-nokia and Copilot
SurbhiAgarwal1 aac01fc
Replace gcr.io container image references with ghcr.io (#4428)
aravindtga 7104724
Proofreading of chapter 1.
mpgreaves 7351b7c
Apply suggestions from code review
mpgreaves fd67e5d
Fix ci failure (#4435)
aravindtga a1346d1
simplify ImageResolveFunc
mozesl-nokia 0cbdf6b
chore: trigger CI rebuild
SurbhiAgarwal1 5c734fb
chore: Remove unwanted files and fix test expectations
SurbhiAgarwal1 78a09a4
docs: add condition field documentation for CEL-based conditional fun…
SurbhiAgarwal1 119350b
Implement Kpt Function Conditional Rendering (Nephio #1084)
SurbhiAgarwal1 867945a
fix: correct condition-not-met expected diff.patch
SurbhiAgarwal1 95bcd15
fix: resolve lint warnings in condition_test.go
SurbhiAgarwal1 526232a
fix: add printer to context in condition_test.go
SurbhiAgarwal1 4524035
feat: Add CEL-based conditional function execution
SurbhiAgarwal1 db051eb
fix: remove k8s.io/apiserver dependency from CEL evaluator
SurbhiAgarwal1 a9f7a7e
refactor: move CELEnvironment to runneroptions, compile program per E…
SurbhiAgarwal1 7478240
Potential fix for pull request finding
SurbhiAgarwal1 6dd9355
refactor: replace Go unit e2e test with proper fn-render testdata
SurbhiAgarwal1 0733226
fix: remove k8s.io/apiserver from go.mod, fix celeval_test.go imports
SurbhiAgarwal1 5b1448f
fix: two e2e test failures in condition testdata
SurbhiAgarwal1 ac17a66
fix: update condition testdata diff.patch with correct expected output
SurbhiAgarwal1 3735f7c
fix: correct e2e testdata and clarify k8s CEL library decision
SurbhiAgarwal1 b12ce5f
fix: update diff.patch with exact hashes from CI output
SurbhiAgarwal1 63bdfcc
feat: add k8s.io/apiserver CEL library extensions (IP, CIDR, Quantity…
SurbhiAgarwal1 281016f
fix: correct SemVer function name to SemverLib in k8s CEL library
SurbhiAgarwal1 06e2896
fix: address Copilot review comments
SurbhiAgarwal1 747ec7c
fix: address PR review feedback from mozesl-nokia and Copilot
SurbhiAgarwal1 bfaff61
Fix #1407: Make 'kpt pkg get' use current directory when '.' is speci…
ciaranjohnston daf7063
Fix linting error: rewrite if-else to switch statement
ciaranjohnston 88ed913
Fix test failures: check cleaned path for '.' and update test expecta…
ciaranjohnston 36063d0
Updated the test checks to be cleaner and more accurate
ciaranjohnston c60056e
Removed unused variable
ciaranjohnston e9fac59
Replace gcr.io container image references with ghcr.io (#4428)
aravindtga 79fc5f6
Proofreading of chapter 1.
mpgreaves 5480903
Apply suggestions from code review
mpgreaves 42435be
Made a minor amendment to the sentence structure.
mpgreaves 8d85ff8
Fix ci failure (#4435)
aravindtga 934e94f
Add RenderStatus to the Kptfile for per-function pipeline result trac…
aravindtga 73a33a6
simplify ImageResolveFunc
mozesl-nokia b77541c
address copilot comments
mozesl-nokia 72d8421
chore: trigger CI rebuild
SurbhiAgarwal1 6a99653
chore: Remove unwanted files and fix test expectations
SurbhiAgarwal1 15d41b2
Implement Kpt Function Conditional Rendering (Nephio #1084)
SurbhiAgarwal1 10897c2
fix: correct condition-not-met expected diff.patch
SurbhiAgarwal1 106fd8a
fix: resolve lint warnings in condition_test.go
SurbhiAgarwal1 30d68a1
fix: add printer to context in condition_test.go
SurbhiAgarwal1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
e2e/testdata/fn-render/condition/condition-met/.expected/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| actualStripLines: | ||
| - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" | ||
|
|
||
| stdErrStripLines: | ||
| - " Stderr:" | ||
| - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" | ||
|
|
||
| stdErr: | | ||
| Package: "condition-met" | ||
| [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/no-op" | ||
| [PASS] "ghcr.io/kptdev/krm-functions-catalog/no-op" in 0s | ||
| Successfully executed 1 function(s) in 1 package(s). |
19 changes: 19 additions & 0 deletions
19
e2e/testdata/fn-render/condition/condition-met/.expected/diff.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| diff --git a/Kptfile b/Kptfile | ||
| index eb90ac3..ace574a 100644 | ||
| --- a/Kptfile | ||
| +++ b/Kptfile | ||
| @@ -5,4 +5,12 @@ metadata: | ||
| pipeline: | ||
| mutators: | ||
| - image: ghcr.io/kptdev/krm-functions-catalog/no-op | ||
| - condition: "resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config')" | ||
| + condition: resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config') | ||
| +status: | ||
| + conditions: | ||
| + - type: Rendered | ||
| + status: "True" | ||
| + reason: RenderSuccess | ||
| + renderStatus: | ||
| + mutationSteps: | ||
| + - image: ghcr.io/kptdev/krm-functions-catalog/no-op | ||
| + exitCode: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .expected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: kpt.dev/v1 | ||
| kind: Kptfile | ||
| metadata: | ||
| name: app | ||
| pipeline: | ||
| mutators: | ||
| - image: ghcr.io/kptdev/krm-functions-catalog/no-op | ||
| condition: "resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config')" |
13 changes: 13 additions & 0 deletions
13
e2e/testdata/fn-render/condition/condition-met/resources.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: app-config | ||
| data: | ||
| key: value | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: my-app | ||
| spec: | ||
| replicas: 1 |
11 changes: 11 additions & 0 deletions
11
e2e/testdata/fn-render/condition/condition-not-met/.expected/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| actualStripLines: | ||
| - " stderr: 'WARNING: The requested image''s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested'" | ||
|
|
||
| stdErrStripLines: | ||
| - " Stderr:" | ||
| - " \"WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\"" | ||
|
|
||
| stdErr: | | ||
| Package: "condition-not-met" | ||
| [SKIPPED] "ghcr.io/kptdev/krm-functions-catalog/no-op" (condition not met) | ||
| Successfully executed 1 function(s) in 1 package(s). |
15 changes: 15 additions & 0 deletions
15
e2e/testdata/fn-render/condition/condition-not-met/.expected/diff.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| diff --git a/Kptfile b/Kptfile | ||
| index eb90ac3..ace574a 100644 | ||
| --- a/Kptfile | ||
| +++ b/Kptfile | ||
| @@ -5,4 +5,9 @@ metadata: | ||
| pipeline: | ||
| mutators: | ||
| - image: ghcr.io/kptdev/krm-functions-catalog/no-op | ||
| - condition: "resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config')" | ||
| + condition: resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config') | ||
| +status: | ||
| + conditions: | ||
| + - type: Rendered | ||
| + status: "True" | ||
| + reason: RenderSuccess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .expected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: kpt.dev/v1 | ||
| kind: Kptfile | ||
| metadata: | ||
| name: app | ||
| pipeline: | ||
| mutators: | ||
| - image: ghcr.io/kptdev/krm-functions-catalog/no-op | ||
| condition: "resources.exists(r, r.kind == 'ConfigMap' && r.metadata.name == 'app-config')" |
6 changes: 6 additions & 0 deletions
6
e2e/testdata/fn-render/condition/condition-not-met/resources.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: my-app | ||
| spec: | ||
| replicas: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the CI failures on this are legitimate. The Kptfile api has been updated to include the renderStatus field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 19bf57c. I've updated both condition test cases to include the renderStatus field in the expected output. The condition-not-met test now shows empty mutationSteps (function skipped), and condition-met shows the function execution with exitCode 0.