-
Notifications
You must be signed in to change notification settings - Fork 109
feat: Add CEL expression evaluator command #2151
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
base: main
Are you sure you want to change the base?
feat: Add CEL expression evaluator command #2151
Conversation
/jira |
💫 Jira ticket created: SRVKP-8026 |
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.
Pull Request Overview
This PR adds a new tkn pac cel
command, providing an interactive and non-interactive REPL for evaluating CEL expressions against real webhook payloads and HTTP headers.
- Introduces the
cel
subcommand in the CLI root. - Implements provider detection, event parsing, and an interactive readline-based REPL.
- Adds comprehensive tests and updates documentation.
Reviewed Changes
Copilot reviewed 7 out of 41 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
pkg/cmd/tknpac/root.go | Register the new cel command under tkn pac |
pkg/cmd/tknpac/cel/templates/help.tmpl | Create help template with available variables & examples |
pkg/cmd/tknpac/cel/cel.go | Implement cel command logic, provider detection, REPL |
pkg/cmd/tknpac/cel/cel_test.go | Add extensive unit tests covering parsing, evaluation, providers, flags, files |
pkg/cel/cel.go | Extend CEL environment to include direct variables |
docs/content/docs/guide/cli.md | Document usage for tkn pac cel |
go.mod | Add github.com/chzyer/readline dependency |
Comments suppressed due to low confidence (2)
docs/content/docs/guide/cli.md:425
- [nitpick] The example headers block includes
Request method: POST
, which is not a standard HTTP header and will be treated as a custom key by the parser. Consider removing or clarifying this line.
Request method: POST
pkg/cel/cel.go:55
- [nitpick] The body is marshaled then unmarshaled to a map for CEL. If
body
is already a map or structured data, avoid the double marshal/unmarshal by type asserting or converting directly.
decls.NewVariable("headers", mapStrDyn),
🤖 AI Review provided by gemini:gemini-2.5-pro:Excellent! This is a substantial and well-thought-out feature commit. It adds a powerful new Here is a careful analysis of the changes, highlighting potential bugs, spelling mistakes, and code improvements. Summary of AnalysisOverall, this is a high-quality commit. The core logic is solid, and the feature is well-implemented with good test coverage. The identified issues are relatively minor and easy to address.
🐛 Bugs & Potential IssuesThese are items that could cause incorrect behavior under certain conditions.
📝 Spelling and DocumentationThese are minor typos and clarifications in comments and documentation.
💡 Code Improvements & Idiomatic GoThese are suggestions to make the code cleaner, more robust, or more idiomatic.
Final VerdictThis is an excellent commit that adds a very useful feature. The implementation is robust, especially with the fallback from |
/retest |
/lgtm |
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.
Congrats @chmouel your PR Has been approved 🎉
✅ Pull Request Approved
Approval Status:
- Required Approvals: 1
- Current Approvals: 1
👥 Reviewers Who Approved:
Reviewer | Permission Level | Approval Status |
---|---|---|
@zakisk | admin |
✅ |
📝 Next Steps
- Ensure all required checks pass
- Comply with branch protection rules
- Request a maintainer to merge using the
/merge
command (or merge it
directly if you have repository permission).
Automated by the PAC Boussole 🧭
/retest |
17052ff
to
e3c0d9c
Compare
This commit introduces a new command `tkn pac cel` that allows users to interactively evaluate CEL (Common Expression Language) expressions. The command is designed to help users test and debug CEL expressions, which are commonly used in Pipelines-as-Code. Key features include: - Interactive and non-interactive modes. - Support for webhook payloads and headers. - Provider auto-detection (GitHub, GitLab, Bitbucket Cloud, Bitbucket Data Center, Gitea). - Direct access to variables as per PAC documentation. - Cross-platform history with readline experience. - Comprehensive help and example expressions. Signed-off-by: Chmouel Boudjnah <[email protected]> feat: Support gosmee-generated shell scripts for headers - Allow the CLI to parse headers from gosmee scripts. - Add support for JSON, plain text and gosmee scripts header formats. - Update documentation to reflect the changes in the header file formats. - Add tests to validate the script and header parsing. Signed-off-by: Chmouel Boudjnah <[email protected]>
e3c0d9c
to
e7347b5
Compare
it is LGTM, do I merge or you wanna make more changes? |
@zakisk i think wait for it, there is some edge case that makes it buggy compared to live event... i'll let you know if we keep it "as is" |
Changes
This commit introduces a new command
tkn pac cel
that allows users to interactively evaluate CEL (Common Expression Language) expressions. The command is designed to help users test and debug CEL expressions, which are commonly used in Pipelines-as-Code.Screen.Recording.2025-06-30.at.11.mp4
Key features include:
JIRA: https://issues.redhat.com/browse/SRVKP-8026
Submitter Checklist
📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).
♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.
✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).
📖 Document any user-facing features or changes in behavior.
🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.
🎁 If feasible, add an end-to-end test. See README for details.
🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).
If adding a provider feature, fill in the following details:
(update the provider documentation accordingly)