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

Fix arity for template in eventlistener triggers #1242

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

madbence
Copy link
Contributor

@madbence madbence commented Oct 15, 2021

Changes

I think a inside an EventListener, you can only specify a single TriggerTemplate, eg. the following works:

apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
  name: my-listener
spec:
  triggers:
    - bindings:
        - ref: my-binding
      template:
        ref: my-template

But this won't:

apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
  name: my-listener
spec:
  triggers:
    - bindings:
        - ref: my-binding
      template:
        - ref: my-template
        - ref: my-template

I've got this error when I tried to apply it:

admission webhook "webhook.triggers.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: cannot unmarshal array into Go struct field EventListenerTrigger.spec.triggers.template of type v1beta1.TriggerSpecTemplate

(the same happened for both triggers.tekton.dev/v1beta1 and triggers.tekton.dev/v1alpha1)

I'm definitely not an expert in tekton internals, but I found the following definitions, and it looks like that only a single TriggerTemplate is supported:

type EventListenerTrigger struct {
Bindings []*EventListenerBinding `json:"bindings,omitempty"`
Template *EventListenerTemplate `json:"template,omitempty"`
TriggerRef string `json:"triggerRef,omitempty"`
// +optional
Name string `json:"name,omitempty"`
Interceptors []*EventInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// more granular authorization for
// who is allowed to utilize the associated pipeline
// vs. defaulting to whatever permissions are associated
// with the entire EventListener and associated sink facilitates
// multi-tenant model based scenarios
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

type EventListenerTrigger struct {
Bindings []*EventListenerBinding `json:"bindings,omitempty"`
Template *EventListenerTemplate `json:"template,omitempty"`
TriggerRef string `json:"triggerRef,omitempty"`
// +optional
Name string `json:"name,omitempty"`
Interceptors []*EventInterceptor `json:"interceptors,omitempty"`
// ServiceAccountName optionally associates credentials with each trigger;
// more granular authorization for
// who is allowed to utilize the associated pipeline
// vs. defaulting to whatever permissions are associated
// with the entire EventListener and associated sink facilitates
// multi-tenant model based scenarios
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

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

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Oct 15, 2021
@tekton-robot tekton-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 15, 2021
@tekton-robot
Copy link

Hi @madbence. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@savitaashture
Copy link
Contributor

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 16, 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

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: savitaashture

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 Oct 16, 2021
@tekton-robot tekton-robot merged commit 723a3c7 into tektoncd:main Oct 16, 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesnt merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants