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

Migrate core interceptors to new format #1029

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Apr 1, 2021

Changes

This commit updates the defaulting webhook to automatically set any Triggers
using the old style syntax for core interceptors to the new ref/params based
syntax.

Fixes #1009

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

Any new Triggers created using the old style syntax for core interceptors is now automatically switched to the new refs/params based syntax.

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Apr 1, 2021
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 1, 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/trigger_defaults.go 100.0% 83.3% -16.7
pkg/apis/triggers/v1alpha1/trigger_types.go 100.0% 78.3% -21.7

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2021
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 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_defaults.go 100.0% 95.0% -5.0
pkg/apis/triggers/v1alpha1/trigger_defaults.go 100.0% 83.3% -16.7
pkg/apis/triggers/v1alpha1/trigger_types.go 100.0% 76.6% -23.4

@dibyom dibyom marked this pull request as ready for review April 2, 2021 19:06
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2021
@dibyom
Copy link
Member Author

dibyom commented Apr 2, 2021

(The drop in coverage is due to missing tests for some err cases where the error happens due to malformed JSON. this should never happen in practice since we are converting from concrete structs)

@dibyom
Copy link
Member Author

dibyom commented Apr 2, 2021

/hold cancel

/assign @wlynch
/assign @savitaashture

@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 Apr 2, 2021
@savitaashture
Copy link
Contributor

savitaashture commented Apr 5, 2021

(The drop in coverage is due to missing tests for some err cases where the error happens due to malformed JSON. this should never happen in practice since we are converting from concrete structs)

👍

How about to pass invalid json data from testcase to increase the coverage 🤔

Otherwise
/lgtm

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Mostly LGTM! Just one small concern around pointer derefs.

ti.Params = []InterceptorParams{}
switch ti.Ref.Name {
case "bitbucket":
if err := addToParams(&ti.Params, "secretRef", ti.DeprecatedBitbucket.SecretRef); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

These could nil panic if ti or DeprecatedBitbucket is nil. We should add checks to prevent this (as well as for the other fields)

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a check for when ti is nil.
A bit convoluted but the checks for the other fields being not nil happens in the call ti.GetName() which ensures that if the name is bitbucket, then ti.DeprecatedBitbucket is not nil: https://github.com/tektoncd/triggers/blob/main/pkg/apis/triggers/v1alpha1/trigger_types.go#L145

@dibyom
Copy link
Member Author

dibyom commented Apr 6, 2021

How about to pass invalid json data from testcase to increase the coverage 🤔

That's going to be hard since we are not actually passing JSON but a TriggerInterceptor struct which will always serialize to valid JSON.

This commit updates the defaulting webhook to automatically set any Triggers
using the old style syntax for core interceptors to the new ref/params based
syntax.

Fixes tektoncd#1009

Signed-off-by: Dibyo Mukherjee <[email protected]>
@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_defaults.go 100.0% 95.0% -5.0
pkg/apis/triggers/v1alpha1/trigger_defaults.go 100.0% 83.3% -16.7
pkg/apis/triggers/v1alpha1/trigger_types.go 100.0% 77.6% -22.4

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2021
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2021
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: savitaashture, 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:
  • OWNERS [savitaashture,wlynch]

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 merged commit e2848d8 into tektoncd:main Apr 7, 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.

Migrate deprecated TriggerInterceptors to new API
4 participants