-
Notifications
You must be signed in to change notification settings - Fork 420
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
Add Conditionals to Resource Creation #49
Comments
So, the |
I believe we should be using Tekton pipeline |
I feel it's a little heavy, |
@vincent-pli That's true. I made a point in counter argument to the |
This work is still blocked, but I think discussion in the issues like this is great. Opinions? @bobcatfish @ncskier @iancoffey @EliZucker |
So to clarify, today we have something like: http:
headerMatch:
foo=bar We could extend this to support more advanced filtering with something like: http:
headerMatch:
foo=bar
bodyMatch:
a.b.c=foo Where a.b.c is a nested json field. Other questions:
|
The header match field is sort of a contrived way of allowing access to the headers without having to introduce a new interpolation variable (like |
Adding a usecase here in support of regex: On a previous team we used a regex branch match to determine whether a CI pipeline should run in response to a push event or not. I forget the exact pattern but it was something relatively simple/naive like "ignore branches named master, qa, and dev": |
I have a feeling that no matter what we do, people are going to want to express more complex Conditions eventually. Here's an example of some slightly more complicated logic a person might want to use: https://github.com/wlynch/cel-playground/tree/get-commit#example-expressions
That's using a language called CEL and it's conceivable that folks will very quickly want to:
I think we can find ways to optimize this, for example I think @dibyom has proposed in Pipelines having ways to more easily express common operations. And I'm not against having a regex type of Condition that maybe gets executed in some optimized way. Are we certain that this is too heavy? I'd be interested to see what the startup time is for a pod that does nothing but run a very tiny container, e.g. a regex container. |
Definitely not, but it was my main/only consideration in opposition to utilizing containers. I think providing some optimized conditional checks down the line (should they be necessary) is a great point. Also, it wouldn't be very secure to match some potentially secret authentication header in plaintext. Using a container, a secret or such could be mounted. If nothing else than the sake of simplicity (rather than engineering matching piece meal), I think containers are the way to go 👍 |
Some relevant discussion here as well: #45 (comment) |
Current status from WG: We have already integrated validation of Triggers using tasks, which validates the event source. This issue should create a separate
|
Whoever picks this up should also add the test builder(s) for the validation task fields within the |
/assign I am taking this task. Will send pr for #117 and then work on this. According to discussion, it's schedule for 0.2 release but may be we can push for it to be release with 0.1. Will see. |
We should be wary of the Pod proliferation problem discussed in issue #125 which led to the creation of the interceptors. |
Might be worth considering using JsonPath here as well as (#178). I'm definitely for lightweight conditional filtering without making more pods. As a user though whichever language is used to navigate and select object properties should likely also be used for conditionals if that functionality is available. |
@kav Regarding this, allowing conditional filters also allows the potential for people to use them as validators, which was the reason we replaced them with interceptors. |
That makes sense to a degree but when I looked at interceptors as an option they felt a bit heavy when all I really wanted was a bit of string equality comparison on a property or two, though I'll admit it does seem like a pretty robust solution to validation, filtering, and any clean up or data conversion |
I meant to specify conditional filters as containers, my apologies for any confusion. I have been back and forth on the container issue, but in consideration for the security, I have come back to my skepticism. I agree interceptors might be too heavy weight in many circumstances and we could add string comparisons (and maybe regex), which might handle most cases. This has been discussed since the initial MVP so I don't entirely consider this "extra behavior" for Triggers, but ideally, I would keep Triggers as slim as possible so as not to reinvent the wheel. |
As per the design document, we will be using CEL to satisfy this conditional/filter request so that interceptors are reusable. This should also enable people to get away with simple validation as well outside of VCS like GitHub, GitLab, etc. |
@dibyom I had a very rough go at this last week https://github.com/bigkevmcd/triggers/tree/master/pkg/interceptors/cel |
Awesome! @wlynch mentioned that we could consider a "core" CEL interceptor as an alternative to a top level |
This adds a cel interceptor, that uses a a CEL expression to filter request bodies. This addresses issue tektoncd#49.
This adds a cel interceptor, that uses a a CEL expression to filter request bodies. This implements issue tektoncd#49.
This adds a cel interceptor, that uses a a CEL expression to filter request bodies. This implements issue tektoncd#49.
This adds a cel interceptor, that uses a a CEL expression to filter request bodies. This implements issue tektoncd#49.
This adds a cel interceptor, that uses a a CEL expression to filter request bodies. This implements issue #49.
Now that CEL interceptor is in there, I'd like to see if we can't agree on how to do CEL munging, i.e. the original triggers:
- name: cel-trig
interceptor:
cel:
filter: "headers.match('X-GitHub-Event', 'pull_request')"
values:
"pr.url": body.pull_request.url
"pr.short_sha": truncate(body.head.sha, 7) I'd propose something similar, I don't have a better name than values, but I think it should be a list of key/values, with "key" and "expression" as the keys for each thing to update. so... triggers:
- name: cel-trig
interceptor:
cel:
filter: "headers.match('X-GitHub-Event', 'pull_request')"
values:
- key: pr.url
expression: body.pull_request.url
- key: pr.short_sha
expression: truncate(body.head.sha, 7) This would be used in the same way as the original values implementation, i.e. if the filter was successful, using This allows an interceptor to add custom keys to the body, or, modify existing ones if it wants to. |
Yeah, using to modify body will be an interesting feature though I think we should track it in its own issue. I'll close this and open a new one for that! |
Expected Behavior
Users should be able to specify a
Conditional
against event payload values to ensure that resources are generated dependent on the payload data. For context, webhook POST data from GitHub specifies the source organization/repository/branch. Users will want to makeTriggerBindings
that execute against particular branches, etc.Actual Behavior
Currently, this is no conditional creation.
Additional Info
Add
Conditionals
to theTriggerBindingSpec
. Values should be interpolated from the event into the fields being asserted. Documentation should be included.The text was updated successfully, but these errors were encountered: