Skip to content
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

Merged
merged 1 commit into from
Aug 22, 2019

Conversation

vtereso
Copy link

@vtereso vtereso commented Aug 6, 2019

Changes

Modify EventListener/TriggerBinding to promote TriggerBinding reuse. Without this change, the additions of conditions and headers within the TriggerBinding would have prevented them from being reusable. Now, input parameters can be specified from the EventListener such that TriggerBindings can be used between multiple EventListeners.

Also, this PR connects TriggerBindings and TriggerTemplates in a one-to-one relationship. My reasoning is that when validation is added, it would be most clear to validate all outputParams from the TriggerBinding against all params in the TriggerTemplate. 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:

@tekton-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 6, 2019
@vtereso vtereso force-pushed the Issue55-ReusableBindings branch 4 times, most recently from d8d2ca4 to 41336d4 Compare August 7, 2019 13:48
@vtereso
Copy link
Author

vtereso commented Aug 7, 2019

@EliZucker how does this look?

@vtereso
Copy link
Author

vtereso commented Aug 7, 2019

Waiting on #67
/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 7, 2019
@vtereso vtereso force-pushed the Issue55-ReusableBindings branch 6 times, most recently from 15ce3d2 to 10af96d Compare August 7, 2019 16:41
@vtereso vtereso force-pushed the Issue55-ReusableBindings branch 6 times, most recently from 3834c0a to 7fef8e7 Compare August 8, 2019 18:17
@vtereso
Copy link
Author

vtereso commented Aug 14, 2019

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 14, 2019
@vtereso vtereso force-pushed the Issue55-ReusableBindings branch 3 times, most recently from bfbe173 to afe3698 Compare August 14, 2019 21:27
@vtereso
Copy link
Author

vtereso commented Aug 15, 2019

This PR places connects a serviceAccount per trigger, but another approach could be to have a single serviceAccount for the entire EventListener.

Copy link
Collaborator

@bobcatfish bobcatfish left a 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)

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
docs/eventlisteners.md Outdated Show resolved Hide resolved
docs/triggerbindings.md Outdated Show resolved Hide resolved
- name: gitrevision
value: $(event.head_commit.id)
- name: gitrepositoryurl
value: $(event.repository.url)
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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

Copy link
Member

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"`
Copy link
Collaborator

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 🤔 )

Copy link
Author

@vtereso vtereso Aug 15, 2019

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.

Copy link
Collaborator

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?)

Copy link
Member

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.

pkg/apis/triggers/v1alpha1/event_listener_types.go Outdated Show resolved Hide resolved
Copy link
Member

@EliZucker EliZucker left a 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)
Copy link
Member

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"`
Copy link
Member

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.

@EliZucker
Copy link
Member

/test pull-tekton-triggers-build-tests

@EliZucker
Copy link
Member

/retest

@EliZucker EliZucker force-pushed the Issue55-ReusableBindings branch from c91ccc0 to 2d07ce4 Compare August 20, 2019 14:48
@vtereso
Copy link
Author

vtereso commented Aug 20, 2019

@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 EventListener creates a single deployment (where the podTemplate takes one serviceAccount). ServiceAccountName as a result should live directly under spec. Also, since we are likely not using input params in the TriggerBinding, maybe params (as prior) is more appropriate than outputParams?

@vtereso
Copy link
Author

vtereso commented Aug 20, 2019

Another improvement could also clean up the json tags:
json:"triggerBinding" -> json:"binding"
json:"triggerTemplate" -> json:"template"

@EliZucker EliZucker force-pushed the Issue55-ReusableBindings branch from 2d07ce4 to 574e227 Compare August 20, 2019 20:12
@EliZucker
Copy link
Member

@vtereso All really good points, thanks. Should be updated now.

@EliZucker EliZucker force-pushed the Issue55-ReusableBindings branch 2 times, most recently from f553b7b to 504db96 Compare August 20, 2019 20:57
Copy link
Collaborator

@bobcatfish bobcatfish left a 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.
Copy link
Collaborator

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"

Copy link
Member

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)
Copy link
Collaborator

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]>
@EliZucker EliZucker force-pushed the Issue55-ReusableBindings branch from 504db96 to de67026 Compare August 22, 2019 20:07
@bobcatfish
Copy link
Collaborator

Thanks for the commit message update!

Let's do this 😎

image

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 22, 2019
@tekton-robot tekton-robot merged commit f61c392 into tektoncd:master Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal to move TriggerBinding-TriggerTemplate connection out of TriggerBinding definition
5 participants