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

Adds annotation to disable payload validation in eventlistener #1189

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

sm43
Copy link
Member

@sm43 sm43 commented Aug 17, 2021

This adds an annotation support tekton.dev/payload-validation
for eventlistener. If it is added to el with value as false then
the payload from events will not be validated and will be directly
passed to interceptors.
By default the payload validation is enabled. Only if annotation
is defined and its value is false then it will be disabled
for that particular el.

Closes #1152

Signed-off-by: Shivam Mukhade [email protected]

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes

User can define an annotation on eventlistener tekton.dev/payload-validation: "false" to disable the payload validation in that event listener. By default payload validation is enabled.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 17, 2021
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 17, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/apis/triggers/v1beta1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/reconciler/eventlistener/eventlistener.go 77.5% 77.2% -0.3
pkg/sink/validate_payload.go 77.8% 78.9% 1.2

Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks fine.
quick bike shed on the actual flag name -- disable-payload-validation vs enable-payload-validation (true by default). Or even validate-payload

I think enable-payload-validation: true sounds clearer than disable-payload-validation: false

@sm43 sm43 force-pushed the disable-json-validation branch from d93c377 to ae0e5a0 Compare August 19, 2021 08:14
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/apis/triggers/v1beta1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/reconciler/eventlistener/eventlistener.go 77.5% 77.2% -0.3
pkg/sink/validate_payload.go 77.8% 78.9% 1.2

@sm43 sm43 force-pushed the disable-json-validation branch from ae0e5a0 to 57d6c66 Compare August 19, 2021 08:25
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/apis/triggers/v1beta1/event_listener_validation.go 97.7% 97.8% 0.1
pkg/reconciler/eventlistener/eventlistener.go 77.5% 77.2% -0.3
pkg/sink/validate_payload.go 77.8% 78.9% 1.2

@sm43
Copy link
Member Author

sm43 commented Aug 19, 2021

/test pull-tekton-triggers-integration-tests

@savitaashture
Copy link
Contributor

code looks fine.
quick bike shed on the actual flag name -- disable-payload-validation vs enable-payload-validation (true by default). Or even validate-payload

I think enable-payload-validation: true sounds clearer than disable-payload-validation: false

yup keeping default value as true enable-payload-validation: true and if user want to disable it they can pass it as false as part of controller.yaml similar to -el-security-context

@sm43
Copy link
Member Author

sm43 commented Aug 23, 2021

code looks fine.
quick bike shed on the actual flag name -- disable-payload-validation vs enable-payload-validation (true by default). Or even validate-payload
I think enable-payload-validation: true sounds clearer than disable-payload-validation: false

yup keeping default value as true enable-payload-validation: true and if user want to disable it they can pass it as false as part of controller.yaml similar to -el-security-context

@savitaashture so do you mean to have field in config-defaults to change the default value at controller level?
and annotation would be at eventlistener level to toggle the value?
if we ask users to edit deployment and if it is installed using Operator then this would get overridden,

@sm43 sm43 force-pushed the disable-json-validation branch from 57d6c66 to 6e66fb5 Compare August 24, 2021 05:21
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2021
@sm43 sm43 force-pushed the disable-json-validation branch from 6e66fb5 to 377d75b Compare August 24, 2021 05:28
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 24, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/event_listener_validation.go 97.7% 97.7% 0.0
pkg/apis/triggers/v1beta1/event_listener_validation.go 97.7% 97.7% 0.0
pkg/apis/triggers/validation.go Do not exist 100.0%
pkg/reconciler/eventlistener/eventlistener.go 77.5% 77.3% -0.3
pkg/sink/validate_payload.go 75.0% 76.2% 1.2

This adds an annotation support tekton.dev/payload-validation
for eventlistener. If it is added to el with value as false then
the payload from events will not be validated and will be directly
passed to interceptors.
By default the payload validation is enabled. Only if annotation
is defined and its value is false then it will be disabled
for that particular el.

Signed-off-by: Shivam Mukhade [email protected]
@sm43 sm43 force-pushed the disable-json-validation branch from 377d75b to 2f6683a Compare August 24, 2021 05:34
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/event_listener_validation.go 97.7% 97.7% 0.0
pkg/apis/triggers/v1beta1/event_listener_validation.go 97.7% 97.7% 0.0
pkg/apis/triggers/validation.go Do not exist 100.0%
pkg/reconciler/eventlistener/eventlistener.go 77.5% 77.3% -0.3
pkg/sink/validate_payload.go 75.0% 76.2% 1.2

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 24, 2021
Copy link
Contributor

@savitaashture savitaashture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
Thank you 👍

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2021
@tekton-robot tekton-robot merged commit 48d8917 into tektoncd:main Aug 25, 2021
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

0.12: PR #969 breaks custom interceptors that convert non-json to JSON
4 participants