title | authors | creation-date | last-updated | status | |
---|---|---|---|---|---|
embedded-trigger-templates |
|
2020-10-01 |
2020-10-01 |
implementable |
This TEP proposes an addition to the Triggers API spec to allow users to embed TriggerTemplate resources inside a Trigger/EventListener.
Embedding a resource inside another is a popular pattern in Tekton. While being able to reference other resources has many uses e.g. resuability, embedding resources makes it simple (and less verbose) to express workflows in Tekton. This is especially true for simple use cases, examples, and documentation where reusability is less of a concern. For instance, Task specs can be embedded inside TaskRuns (see the examples).
Within a Trigger, at the moment, only bindings
can be embedded while Templates
always have to be referenced. Allowing embedded templates will make it easier
for users to create simple Triggers as well as make our examples and
documentation less verbose and easier to understand.
- Make an additive change to the Triggers API to support embedded TriggerTemplate specs.
- Changes to the TriggerTemplate Spec itself.
There are two changes proposed to the Trigger spec:
- Add an optional
spec
field of typeTriggerTemplateSpec
to a Trigger'sspec.Template
. Example:
template:
spec:
params:
- name: "name"
resourceTemplates:
- apiVersion: "tekton.dev/v1beta1"
kind: TaskRun
metadata:
generateName: "pr-run-"
spec:
taskSpec:
steps:
- image: ubuntu
script: echo "hello there $(tt.params.name)"
- Deprecate the
name
field for reffering to TriggerTemplate objects in favor of a newref
field. This is for consistency as we use usually useref
to refer to other resources (seebindings
as an example). Example:# DEPRECATED template: name: "my-tt" # NEW template: ref: "my-tt"
For the name
to ref
change, we'll make the upgrade process backwards
compatible:
-
For the next release, we'll support both
name
andref
fields while markingname
as deprecated. -
We'll use a mutating admission webhook to change
name
fields toref
for any newly created/updated Triggers/EventListeners. -
In a future release, we'll remove the
name
field from the spec.
-
GitHub issue: tektoncd/triggers#616
-
Embedded Bindings: https://github.com/tektoncd/community/blob/master/teps/0016-concise-trigger-bindings.md