-
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
Issue55 reusable bindings #63
Issue55 reusable bindings #63
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vtereso 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 |
d8d2ca4
to
41336d4
Compare
@EliZucker how does this look? |
Waiting on #67 |
15ce3d2
to
10af96d
Compare
3834c0a
to
7fef8e7
Compare
/hold cancel |
bfbe173
to
afe3698
Compare
This PR places connects a serviceAccount per trigger, but another approach could be to have a single serviceAccount for the entire EventListener. |
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.
Nice, I think this is an improvement for sure!!! I left a bunch of random comments, I think my feedback is:
- I think it could make sense to remove validation from TriggerBinding (I'm happy to open an issue if there isn't one already)
- We should get docstrings into our
_types.go
asap (esp. as we make changes, to make it clear to everyone what the fields were doing and what they will do)
Also @vtereso could you add some more details to the commit message? Right now it just says "Restructure TriggerBinding to make them reusable" but it would make sense to summarize (as briefly as possible) the conclusions reached in #55 to explain the context of the change - more tips in the commit message guidelines)
- name: gitrevision | ||
value: $(event.head_commit.id) | ||
- name: gitrepositoryurl | ||
value: $(event.repository.url) |
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.
can we show inputParams
and the other fields in this example as well, and document how they work?
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 we don't have conditionals/header matching yet, I omitted them for the time being.
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.
hm id rather either:
- not include them in the types until we're ready to document them
- include them in the docs but not have the functionality (which is what we've done for most other types anyway)
my personal feeling is that before 0.1 it's okay to have our docs be aspirational - if we intend to have the functionality in 0.1, i think we can put it in the docs before it actually works (as long as it does before 0.1). but if we dont intend to include it in 0.1, i dont think we should include the types in the code at all
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 TriggerTemplates may not even take params if #71 goes through, and also to keep this PR lightweight to meet the milestone, I have removed params from the types until we're ready to implement and document them.
type Trigger struct { | ||
TriggerBinding TriggerBindingRef `json:"triggerBinding"` | ||
TriggerTemplate TriggerTemplateRef `json:"triggerTemplate"` | ||
ServiceAccountName string `json:"serviceAccountName"` |
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.
can we have docstrings for all the structs + attributes we're adding?
(looks like we need to turn on more linting maybe, there should be linting that catches when exported values don't have docstrings 🤔 )
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.
Adding -E golint
to our lint command (golangci-lint run
) should allow us to get this behavior, but when I tried it only complained about naming stutter errors. Maybe open an issue for it? Pipelines doesn't seem to have this enabled either.
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.
kk! Ive opened tektoncd/plumbing#64 in the plumbing repo so hopefully we can get this for both projects :D (and cli too?)
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.
For now, I have added docstrings for the existing public types.
66a02cf
to
9f984cd
Compare
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 have addressed the existing comments on this PR. Ready for more feedback or lgtm!
- name: gitrevision | ||
value: $(event.head_commit.id) | ||
- name: gitrepositoryurl | ||
value: $(event.repository.url) |
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 TriggerTemplates may not even take params if #71 goes through, and also to keep this PR lightweight to meet the milestone, I have removed params from the types until we're ready to implement and document them.
type Trigger struct { | ||
TriggerBinding TriggerBindingRef `json:"triggerBinding"` | ||
TriggerTemplate TriggerTemplateRef `json:"triggerTemplate"` | ||
ServiceAccountName string `json:"serviceAccountName"` |
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.
For now, I have added docstrings for the existing public types.
/test pull-tekton-triggers-build-tests |
/retest |
c91ccc0
to
2d07ce4
Compare
@EliZucker Nice updates. I thought it would be nice to have one service account per trigger to separate the permissions, but actually only one service account can be used (at the moment) since each |
Another improvement could also clean up the json tags: |
2d07ce4
to
574e227
Compare
@vtereso All really good points, thanks. Should be updated now. |
f553b7b
to
504db96
Compare
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.
Looking great! I am completely ready to lgtm, but the one request I have is can we add more context to the commit message? (e.g. see https://github.com/tektoncd/community/blob/master/standards.md#commit-messages) 🙏
func (t *TriggerBinding) Validate(ctx context.Context) *apis.FieldError { | ||
return t.Spec.Validate(ctx) | ||
} | ||
|
||
// Validate TriggerBindingSpec. |
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.
if you feel like it, this is a place where it would make sense to say something like "there is nothing to validate in a TriggerBindingSpec b/c xyz"
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 comment reminded me there actually is a bit of validation we can do... Added now.
} | ||
log.Print(tt) |
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.
we're going to want to start adding unit tests for the eventlistener asap but np if you dont want to do it in this PR
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]>
504db96
to
de67026
Compare
Changes
Modify
EventListener
/TriggerBinding
to promoteTriggerBinding
reuse. Without this change, the additions of conditions and headers within theTriggerBinding
would have prevented them from being reusable. Now, input parameters can be specified from theEventListener
such thatTriggerBindings
can be used between multipleEventListeners
.Also, this PR connects
TriggerBindings
andTriggerTemplates
in a one-to-one relationship. My reasoning is that when validation is added, it would be most clear to validate all outputParams from theTriggerBinding
against all params in theTriggerTemplate
. In this way, the template should likely do everything necessary rather than segment everything between different templates. Also, between templates there is no way to cross reference generated resources, which could be another point of confusion if this was supported.UPDATE: As per the WG discussion, it seems we are aligned in the one-to-one
TriggerBinding
-TriggerTemplate
approach.Fixes #55
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them: