-
Notifications
You must be signed in to change notification settings - Fork 426
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
Proposal to move TriggerBinding-TriggerTemplate connection out of TriggerBinding definition #55
Comments
The way I understand it, the However much to your point/previous discussions, considering the use case of the same (using the current design) To further this thought, I see a potential problem. Likely, there would have also been a I see merit in this design, but I think this needs to be adjusted slightly, but I'm not sure how. I wonder if someone else has another use case? Also just a nit, a |
Oh right, I was staring at the YAML in the docs and forgot that the spec is a slice of The merit of this proposal depends on the complexity of user payloads. If we are intending to target simple projects where all you might need to extract is something like the commit ID and repository URL, then my suggestion might not make sense. But with large complex payloads, it might be worth decoupling the field-capturing logic from a particular set of
Point 1 can be reused, but 2 and possibly 3 are project-specific. I just wonder if users will want to be able to separate the field-separating logic... It's easy to overlook this right now because we're envisioning such simple payloads. |
I completely agree that the first point is an area that could be reused. Assuming there were multiple different |
I wonder if we could list reasons why Not saying I think one way or another, but it seems kind of arbitrary to me that If only one can be reusable (and I'm not saying this should be the case), then is it more valuable to users that they can reuse payload parameter extraction logic or that they can reuse the logic that turns those parameters into other resources? Our current design seems to imply that the second one is more important. |
A compromise solution:
Then |
This seems analogous to moving only the headers into the |
Sorry I'm jumping into this conversation a little late; thanks for writing up this proposal Eli! 👍
I think it makes more sense to put the filtering/conditional information in the TriggerBinding (possibly conditional info can go in the TriggerTemplate though?). This is because I like the clear division of information in our current design. The EventListener only knows about the addressable endpoint information (deployment + service configurations). The TriggerBinding only knows about the event information, and how it maps to parameters. The TriggerTemplate only knows about what resources to create, and how to inject its parameters into these resources. So, I personally don't like the idea of moving event information into the EventListener.
I think that the TriggerTemplates are definitely more reusable than the TriggerBindings, because the TriggerTemplates are more general-purpose and less specific than TriggerBindings. TriggerTemplates define a set of resources that we want to create & a set of parameters needed to create these resources. This set of resources can be reused in many different contexts given different sets of parameters. For example sending parameters for building & testing one of my GitHub projects, versus building & testing a different GitHub project, versus a GitLab project, etc. the TriggerTemplate is reused to create the same set of resources in each different context. On the other hand, TriggerBindings are much more specific. With the current proposal, TriggerBindings are tied to an event type (for example, a GitHub push event), and they are tied to a specific TriggerTemplate (this connection is more loosely defined, because any TriggerTemplate with the same parameters can be used). So the TriggerBinding cannot be reused as easily as the TriggerTemplate. Furthermore, the TriggerBindings are currently more lightweight than the TriggerTemplates, because they are only mapping parameters from an event payload into the TriggerTemplate parameters. So, it is not very costly to create slightly repetitive TriggerBindings. This isn't to say that the TriggerBindings shouldn't be reusable. However, I don't think the case is as compelling to make them reusable. I do think that how we integrate header filtering & conditional logic could play into the reusability of TriggerBindings. If both header filtering & conditional logic lives in the TriggerBinding, they will become less lightweight, and it might become more compelling for a user to want to reuse TriggerBindings. |
I think this proposal in getting at the heart of something important and I would like to see more reuse as outlined. I have reservation because of the leaky abstraction nature of this, where as currently everything is neatly encapsulated. However, it's a good idea. |
Yeah, thinking about it more, I like the idea of reuse when thinking about a catalog. I don't think that we can decouple the TriggerBinding from the TriggerTemplate. However, I think that it is compelling to have an entry in a catalog with a suite of reusable TriggerBindings & TriggerTemplate(s). For example, consider having a Pipeline that builds and deploys a Go project. In the example catalog entry, I can have a
This catalog scenario makes it very easy for a user with a GitHub project, GitLab project, or BitBucket project to create a webhook to run this Pipeline on their project. To me, this is the most compelling case for reusing TriggerBindings. |
To be clear they're also specifying a target TriggerTemplate, doing header filtering, and allowing for conditionals. I also don't fully understand why @vincent-pli 's solution or any potential solution that moves parts of Additionally, I think that we can have an internal state representation that maintains that abstraction you are talking about. Analogous to pipelines, imagine that fields like |
If we're going to make
So the
In this example, we would only create the resources in the |
yeah I like that proposal above from @ncskier better than the current project design. |
I question how much benefit there is in not including references to the This is a semi-blocker for a few things, so if we are in agreement, can proceed with implementing @ncskier's suggestion? @EliZucker @iancoffey @bobcatfish If so, we can close #56 and it will be under this issue as well? |
I agree with proceeding to implement @ncskier 's suggestion |
/assign |
Very late to the party but in general I think these are some pretty cool improvements! My comments kinda go hand in hand with #62 - when I look at this proposed design: apiVersion: tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: my-triggerbinding
spec:
inputParams:
- name: secret
description: The git webhook secret
- name: branch
description: The git branch
default: master
headerMatches:
- X-GitHub-Event: push
- X-GitHub-Secret: $(inputParams.secret)
conditionals:
- $(event.ref): refs/heads/$(inputParams.branch)
outputParams:
- name: gitrevision
value: $(event.head_commit.id)
- name: gitrepositoryurl
value: $(event.repository.url) I'm wondering a couple of things:
@ncskier was saying:
I like this division of responsibility but for (2), TriggerBinding's responsibilities, I wonder if we are ready to introduce conditions into the design and if this is the right place to do it - I think we can get a first working iteration of triggers without including conditionals? (Correct me if I'm wrong tho - I'm basically assuming we want to target a use case like GitHub PR triggering for our first iteration, and that we don't need conditionals or filtering of any kind to make that happen) (And plus if we want to add Conditionals I'd like to explore making use of Pipeline Conditions if we can! But I'm hoping we can punt on this until we need to :D) |
Could leverage But I prefer to tekton's own |
Modify EventListener and TriggerBinding such that TriggerBindings can be reused. This was proposed and discussed in tektoncd#55 . Instead of specifying a particular TriggerTemplate within a TriggerBinding (as was previously proposed), users now specify one-to-one relationships between TriggerBindings and TriggerTemplates within an EventListener. Catalogs of TriggerTemplates can exist and be reused with this change. Although adding Params may be something we want to do for reusability in the future, particularly for the case where filtering/conditions are embeded within the TriggerBinding, it is out of this PR's scope. We may separate the conditional/filtering logic in which case parameters would make more sense there anyway. Co-authored-by: Vincent-DeSousa-Tereso <[email protected]>
Modify EventListener and TriggerBinding such that TriggerBindings can be reused. This was proposed and discussed in #55 . Instead of specifying a particular TriggerTemplate within a TriggerBinding (as was previously proposed), users now specify one-to-one relationships between TriggerBindings and TriggerTemplates within an EventListener. Catalogs of TriggerTemplates can exist and be reused with this change. Although adding Params may be something we want to do for reusability in the future, particularly for the case where filtering/conditions are embeded within the TriggerBinding, it is out of this PR's scope. We may separate the conditional/filtering logic in which case parameters would make more sense there anyway. Co-authored-by: Vincent-DeSousa-Tereso <[email protected]>
Modify EventListener and TriggerBinding such that TriggerBindings can be reused. This was proposed and discussed in #55 . Instead of specifying a particular TriggerTemplate within a TriggerBinding (as was previously proposed), users now specify one-to-one relationships between TriggerBindings and TriggerTemplates within an EventListener. Catalogs of TriggerTemplates can exist and be reused with this change. Although adding Params may be something we want to do for reusability in the future, particularly for the case where filtering/conditions are embeded within the TriggerBinding, it is out of this PR's scope. We may separate the conditional/filtering logic in which case parameters would make more sense there anyway. Co-authored-by: Vincent-DeSousa-Tereso <[email protected]>
In the docs for
TriggerBinding
s, we say:I don't disagree with this idea and I don't think
TriggerTemplate
reusability should change.However, for many users, it may end up being even more important for
TriggerBinding
s to be reusable!TriggerBinding
reusability is severely limited in the current design because within the definition, a specificTriggerTemplate
is referenced within theTemplateRef
.To give an idea of what I'm saying, imagine a user who is getting tons of GitHub events from various contexts/sources. Depending on the situation, the user has defined several
TriggerTemplate
s, and each will execute different jobs like building code, performing test, moderating comments, etc. Now, for each of thoseTriggerTemplate
s, which are intended to be called upon separately in differently contexts, the user must completely redefine or copy-paste the payload->parameter logic, because that information is withinTriggerBinding
, which is tied to a specificTriggerTemplate
viaTemplateRef
. This could become extremely tedious especially for users with complex payloads.Bottom line, I think
TriggerTemplate
s andTemplateRef
s should each be reusable for their own reasons, and the way to do this is to move theTriggerBinding
→TriggerTemplate
connection representation out of theTriggerBinding
itself. This could be done by moving the connection information a layer up intoEventListener
, or to create a new resource, representing that connection and possible conditional logic and then listing those new connection resources withinEventListener
.My proposal would be to move the connection information into
EventListener
. This would mean removing thetemplateRef
field fromTriggerBinding
s, and then anEventListener
could look something like this:Conditional/filtering information would also go within the
connections
field. This way, the payload-variable logic is truly encapsulated and reusable withintriggerBinding
. I seeEventListener
analogous to aPipelineRun
orTaskRun
, in that it provides project-specific configuration details like connections, filtering, or perhaps default parameter/payload values, whiletriggerBinding
andtriggerTemplate
can be reused as needed.The text was updated successfully, but these errors were encountered: