-
Notifications
You must be signed in to change notification settings - Fork 121
[CEL] Common Expression Language Custom Task #692
Conversation
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.
This looks great! Just a couple comments about docs.
cel/pkg/reconciler/cel/celrun.go
Outdated
} | ||
|
||
// Iterate through the CEL expressions | ||
for _, param := range o.Spec.Params { |
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 think we want to pull out the param named expression
, fail if it isn't found, and only evaluate that param value. This should also fail if any other params are defined, since that's probably a typo/bug.
I don't think we want/need to support multiple expressions in one run, since it's a bit unclear how it should work, and it's probably clearer (though much more verbose) to just have multiple CEL-typed Runs if you want that.
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.
since it's a bit unclear how it should work, and it's probably clearer (though much more verbose) to just have multiple CEL-typed Runs if you want that.
the way I have it implemented now is that the Run
will evaluate each Parameter
and produce a Result
with the corresponding name (i.e. parameter name == result name), did that to reduce the verbosity and evaluate multiple expressions in one pod when appropriate, what do you think of that?
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.
Yeah, I think I'm coming around to it. It is better than having N single-expression Runs.
One possible confusing thing is that if a CEL Run has three expression params and one is an invalid expression, will it fail but still produce results for the other two expressions? Will it still evaluate params defined after the invalid expression? There are some options:
- Fail and don't report any results if any expression param is invalid.
- (this is what this PR does) Evaluate each expression in the order they're defined in
params
, fail when one is invalid and only report results for previous valid evaluations. - Evaluate each expression, fail when one is invalid but keep evaluating params and report results for any that are valid expressions. You can report either the first, or all, invalid expressions in
status
.
Either way I don't think it should block this PR, it'd be better to get usage and feedback.
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.
As a user I would expect it to fail if any param expression is invalid. I think I assume a full validation before it runs
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've added an earlier validation to check that that at least one expression is provided and that the expression types are valid
To be consistent with Tasks
which don't produce Results
when they fail, I've modified so that we go with option 1 where we don't report any evaluation result if any expression is invalid or has any syntax/evaluation error -- and I agree that we can revisit those options based on user feedback
/lgtm |
/lgtm |
/cc @bigkevmcd |
@dibyom: GitHub didn't allow me to request PR reviews from the following users: bigkevmcd. Note that only tektoncd members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This is the initial of an experimental project that provides support for Common Expression Language (CEL) in Tekton Pipelines. The functionality is provided by a controller that implements the Custom Task interface. Its use cases include evaluating complex expressions to be used in [`WhenExpressions`](https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md#guard-task-execution-using-whenexpressions) in subsequent `Tasks` to guard their execution. The `CEL` expressions to be evaluated by the `CELRun` are specified using parameters. As the `Run` executes, its `status` field accumulates information about the execution status of the `Run` in general. If the evaluation is successful, it will also contain the results of the evaluation under `status.results` with the corresponding names of the CEL expressions as provided in the parameters.
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.
Looks really good to me, thanks for taking this on.
/lgtm |
/approve |
1 similar comment
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bigkevmcd, ImJasonH The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
haha, I was still reviewing it 🙃 very excited for this 😍 |
this is experimental so welcoming your feedback and we can modify as needed, could be easier to discuss in the TEP: tektoncd/community#314 |
|
||
A successful `Run` contains the `Results` of evaluating the CEL expressions under `status.results`, with the name of | ||
each evaluation `Result` matching the name of the corresponding CEL expression as provided in the `Parameters`. | ||
Users can reference the `Results` in subsequent `Tasks` using variable substitution, as such: |
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.
hey @jerop sorry for the late comment, just wondering' what's the type and structure of the result? (e.g. json? or some CEL specific thing? maybe we can link to some CEL docs about this?)
Changes
This is the initial of an experimental project that provides support for Common Expression Language (CEL) in Tekton Pipelines.
The functionality is provided by a controller that implements the Custom Task interface. Its use cases include evaluating complex expressions to be used in
WhenExpressions
in subsequentTasks
to guard their execution.To evaluate a CEL expressions using
Custom Tasks
, we need to define aRun
type withapiVersion: cel.tekton.dev/v1alpha1
andkind: CEL
. TheRun
takes the CEL expressions to be evaluated asParameters
.As the
Run
executes, itsstatus
field accumulates information about the execution status of theRun
in general. If the evaluation is successful, it will also contain theResults
of the evaluation understatus.results
with the corresponding names of the CEL expressions as provided in theParameters
. If no CEL expressions are provided, any CEL expression is invalid or there's any other error, theCEL
Custom Task
will fail and the details will be included instatus.conditions
.Related issues:
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.