-
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
Feature: TriggerGroups #1232
Feature: TriggerGroups #1232
Conversation
The following is the coverage report on the affected files.
|
aee6879
to
7f9eacd
Compare
The following is the coverage report on the affected files.
|
Added validation in the webhook. Should probably add another check in the reconciler too
Due to the allowlist in https://github.com/tektoncd/triggers/blob/main/test/e2e-tests-examples.sh#L138, the triggerGroup example would not be run. I'll work on something like https://github.com/tektoncd/pipeline/tree/main/docs/developers#example-yamls in a separate PR to enable the YAML test for this example. |
6227ffe
to
0eee40a
Compare
The following is the coverage report on the affected files.
|
I'll add some extra validation in the reconciler so that the alpha fields cannot be used and rebase the commits but in the meantime, this should be ready for a review |
0eee40a
to
bce959a
Compare
The following is the coverage report on the affected files.
|
bce959a
to
f86b654
Compare
The following is the coverage report on the affected files.
|
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.
Mostly LGTM! Just minor nits.
type EventListenerTriggerGroup struct { | ||
Name string `json:"name"` | ||
Interceptors []*TriggerInterceptor `json:"interceptors"` | ||
TriggerSelector EventListenerTriggerSelector `json:"triggerSelector"` | ||
} | ||
|
||
type EventListenerTriggerSelector struct { | ||
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"` | ||
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` | ||
} | ||
|
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.
Missing godoc comments
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.
Hmm, I thought I removed the types from v1alpha1.
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 removed the types from v1alpha1. They are only available in v1beta1
} | ||
|
||
func (r Sink) selectTriggers(namespaceSelector triggersv1.NamespaceSelector, labelSelector *metav1.LabelSelector) ([]*triggersv1.Trigger, error) { | ||
var trItems []*triggersv1.Trigger |
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.
Move this definition futher down to where its used.
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.
ack. Keeping it here since it is also called by the HandleEvent
function above.
|
||
func (r Sink) selectTriggers(namespaceSelector triggersv1.NamespaceSelector, labelSelector *metav1.LabelSelector) ([]*triggersv1.Trigger, error) { | ||
var trItems []*triggersv1.Trigger | ||
var err error |
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 this can be removed? AFAICT in this func all error handling in this func is immediately followed with
if err != nil {
return err
}
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 its because targetLabels := labels.Everything()
and then assigned to in inside the if, we have to pre-declare the err variable.
@@ -264,10 +328,14 @@ func (r Sink) processTrigger(t triggersv1.Trigger, request *http.Request, event | |||
go r.recordResourceCreation(resources) | |||
} | |||
|
|||
func (r Sink) ExecuteTriggerInterceptors(t triggersv1.Trigger, in *http.Request, event []byte, log *zap.SugaredLogger, eventID string, extensions map[string]interface{}) ([]byte, http.Header, *triggersv1.InterceptorResponse, error) { | |||
return r.ExecuteInterceptors(t.Spec.Interceptors, in, event, log, eventID, fmt.Sprintf("namespaces/%s/triggers/%s", t.Namespace, t.Name), t.Namespace, extensions) |
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.
Optional for this PR, but we might want to look into adding something like https://github.com/tektoncd/pipeline/blob/f8c2eea6ad6370cd290d937d143358e99c2d7ad6/pkg/apis/pipeline/v1beta1/pipelinerun_types.go#L114-L117
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.
ack. will do in a new PR
@@ -1,27 +0,0 @@ | |||
Copyright (c) 2009 The Go Authors. All rights reserved. |
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.
Do we now why these licenses are being deleted?
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.
Not sure, its just what the hack/update-deps.sh script is doing. (I've seen the x/crypto/LICENSE being added/deleted a few times before).
This feature allows an operator to specify a set of interceptors that will be executed before a group of triggers are selected and executed. This allows common data to be passed from interceptor execution down to multiple triggers to solve a set of common use cases across multiple Triggers. This feature is enabled for now inline in the EventListener spec, but in the future may be enabled only in alpha once the feature gates proposal is implemented within this project. Addresses tektoncd#945
f86b654
to
691b204
Compare
The following is the coverage report on the affected files.
|
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.
One last formatting fix, otherwise LGTM
This commit adds validation to ensure that triggerGroups can only be used in the v1beta1 apiVersion when `enable-api-fields` is set to `alpha`.
691b204
to
7da5283
Compare
The following is the coverage report on the affected files.
|
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wlynch 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 |
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` | ||
Resources Resources `json:"resources,omitempty"` | ||
// Trigger groups allow for centralized processing of an interceptor chain | ||
TriggerGroups []EventListenerTriggerGroup `json:"triggerGroups"` |
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.
Trying to update the JSON schema bundled with the IntelliJ and VSCode tooling but realized both Triggers
and TriggerGroups
fields are required. Shouldn't we add the omitempty
annotation ?
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.
Yup we should - they aren't both required in the sense that the validation will both are not provided.
Addresses comment: tektoncd#1232 (comment) Signed-off-by: Dibyo Mukherjee <[email protected]>
Addresses comment: tektoncd#1232 (comment) Signed-off-by: Dibyo Mukherjee <[email protected]>
Addresses comment: #1232 (comment) Signed-off-by: Dibyo Mukherjee <[email protected]>
Addresses comment: tektoncd#1232 (comment) Signed-off-by: Dibyo Mukherjee <[email protected]> (cherry picked from commit 4a9db17)
Addresses comment: #1232 (comment) Signed-off-by: Dibyo Mukherjee <[email protected]> (cherry picked from commit 4a9db17)
Changes
This is a port of #1052 - mostly just fixes so that it can merge cleanly with main
So far I've done the following
enable-api-fields
is set toalpha
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.
Release Notes