Skip to content

Commit

Permalink
Format markdown
Browse files Browse the repository at this point in the history
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
/assign ImJasonH dibyom
/cc ImJasonH dibyom
  • Loading branch information
mattmoor authored and tekton-robot committed Jan 17, 2020
1 parent bc6916b commit 677627f
Show file tree
Hide file tree
Showing 17 changed files with 378 additions and 260 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ For more Triggers specific guidelines, see:

- [The Tekton Triggers ZenHub project](#zenhub-project)

See also [the Tekton Pipelines roadmap](http://github.com/tektoncd/pipeline/blob/master/roadmap-2019.md)
See also
[the Tekton Pipelines roadmap](http://github.com/tektoncd/pipeline/blob/master/roadmap-2019.md)

## ZenHub project

Expand Down
8 changes: 4 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ of the technology this project is built on.

#### Ramp up on CRDs

This project extends Kubernetes (aka
`k8s`) with Custom Resource Definitions (CRDSs). To find out more:
This project extends Kubernetes (aka `k8s`) with Custom Resource Definitions
(CRDSs). To find out more:

- [The Kubernetes docs on Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) -
These will orient you on what words like "Resource" and "Controller"
Expand Down Expand Up @@ -193,8 +193,8 @@ kubectl create clusterrolebinding cluster-admin-binding \
To install [Tekton Pipelines](https://github.com/tektoncd/pipeline) you can
either:

* [Install a released version](https://github.com/tektoncd/pipeline/blob/master/docs/install.md)
* [Setup Tekton Pipelines for development](https://github.com/tektoncd/pipeline/blob/master/DEVELOPMENT.md)
- [Install a released version](https://github.com/tektoncd/pipeline/blob/master/docs/install.md)
- [Setup Tekton Pipelines for development](https://github.com/tektoncd/pipeline/blob/master/DEVELOPMENT.md)
(install and iterate from HEAD)

## Iterating
Expand Down
77 changes: 58 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,76 @@
# Tekton Triggers
Triggers is a Kubernetes [Custom Resource Defintion](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) (CRD) controller that allows you to extract information from events payloads (a "trigger") to create Kubernetes resources.

The contents of this repo originated from implementing [this design](https://docs.google.com/document/d/1fngeNn3kGD4P_FTZjAnfERcEajS7zQhSEUaN7BYIlTw/edit#heading=h.iyqzt1brkg3o)
(visible to members of [the Tekton mailing list](https://github.com/tektoncd/community/blob/master/contact.md#mailing-list)).
Triggers is a Kubernetes
[Custom Resource Defintion](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)
(CRD) controller that allows you to extract information from events payloads (a
"trigger") to create Kubernetes resources.

The contents of this repo originated from implementing
[this design](https://docs.google.com/document/d/1fngeNn3kGD4P_FTZjAnfERcEajS7zQhSEUaN7BYIlTw/edit#heading=h.iyqzt1brkg3o)
(visible to members of
[the Tekton mailing list](https://github.com/tektoncd/community/blob/master/contact.md#mailing-list)).

## Background
[Tekton](https://github.com/tektoncd/pipeline) is a **Kubernetes-native**, continuous integration and delivery (CI/CD) framework that enables you to create containerized, composable, and configurable workloads declaratively through CRDs.
Naturally, CI/CD events contain information that should:
- Identify the kind of event (GitHub Push, Gitlab Issue, Docker Hub Webhook, etc.)
- Be accessible from and map to particular pipelines (Take SHA from payload to use it in pipeline X)
- Deterministically trigger pipelines (Events/pipelines that trigger pipelines based on certain payload values)

The Tekton API enables functionality to be seperated from configuration (e.g. [Pipelines](https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md) vs [PipelineRuns](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md)) such that steps can be reusable, but it does not provide a mechanism to generate the resources (notably, [PipelineRuns](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md) and [PipelineResources](https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#pipelineresources)) that encapsulate these configurations dynamically. Triggers extends the Tekton architecture with the following CRDs:
- [`TriggerTemplate`](docs/triggertemplates.md) - Templates resources to be created (e.g. Create PipelineResources and PipelineRun that uses them)
- [`TriggerBinding`](docs/triggerbindings.md) - Validates events and extracts payload fields
- [`EventListener`](docs/eventlisteners.md) - Connects `TriggerBindings` and `TriggerTemplates` into an [addressable](https://github.com/knative/eventing/blob/master/docs/spec/interfaces.md) endpoint (the event sink). It uses the extracted event parameters from each `TriggerBinding` (and any supplied static parameters) to create the resources specified in the corresponding `TriggerTemplate`. It also optionally allows an external service to pre-process the event payload via the `interceptor` field.
[Tekton](https://github.com/tektoncd/pipeline) is a **Kubernetes-native**,
continuous integration and delivery (CI/CD) framework that enables you to create
containerized, composable, and configurable workloads declaratively through
CRDs. Naturally, CI/CD events contain information that should:

- Identify the kind of event (GitHub Push, Gitlab Issue, Docker Hub Webhook,
etc.)
- Be accessible from and map to particular pipelines (Take SHA from payload to
use it in pipeline X)
- Deterministically trigger pipelines (Events/pipelines that trigger pipelines
based on certain payload values)

The Tekton API enables functionality to be seperated from configuration (e.g.
[Pipelines](https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md)
vs
[PipelineRuns](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md))
such that steps can be reusable, but it does not provide a mechanism to generate
the resources (notably,
[PipelineRuns](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md)
and
[PipelineResources](https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#pipelineresources))
that encapsulate these configurations dynamically. Triggers extends the Tekton
architecture with the following CRDs:

- [`TriggerTemplate`](docs/triggertemplates.md) - Templates resources to be
created (e.g. Create PipelineResources and PipelineRun that uses them)
- [`TriggerBinding`](docs/triggerbindings.md) - Validates events and extracts
payload fields
- [`EventListener`](docs/eventlisteners.md) - Connects `TriggerBindings` and
`TriggerTemplates` into an
[addressable](https://github.com/knative/eventing/blob/master/docs/spec/interfaces.md)
endpoint (the event sink). It uses the extracted event parameters from each
`TriggerBinding` (and any supplied static parameters) to create the resources
specified in the corresponding `TriggerTemplate`. It also optionally allows an
external service to pre-process the event payload via the `interceptor` field.

Using `tektoncd/triggers` in conjunction with `tektoncd/pipeline` enables you to easily create full-fledged CI/CD systems where the execution is defined **entirely** through Kubernetes resources.
This repo draws inspiration from `Tekton`, but can used stand alone since `TriggerTemplates` can create any Kubernetes resource.
Using `tektoncd/triggers` in conjunction with `tektoncd/pipeline` enables you to
easily create full-fledged CI/CD systems where the execution is defined
**entirely** through Kubernetes resources. This repo draws inspiration from
`Tekton`, but can used stand alone since `TriggerTemplates` can create any
Kubernetes resource.

You can learn more by checking out the [docs](docs/README.md)

## Want to start using Tekton Triggers

[Install](./docs/install.md) Triggers, check out the [installation guide](./docs/install.md), [examples](./examples/README.md) or follow the [getting started guide](./docs/getting-started/README.md) to become familiar with the project. The getting started guide walks through setting up an end-to-end image building solution, which will be triggered from GitHub `push` events.
[Install](./docs/install.md) Triggers, check out the
[installation guide](./docs/install.md), [examples](./examples/README.md) or
follow the [getting started guide](./docs/getting-started/README.md) to become
familiar with the project. The getting started guide walks through setting up an
end-to-end image building solution, which will be triggered from GitHub `push`
events.

### Read the docs

| Version | Docs | Examples | Getting Started |
| ------- | ---- | -------- | --------------- |
| [HEAD](https://github.com/tektoncd/triggers/blob/master/DEVELOPMENT.md#install-pipeline) | [Docs @ HEAD](https://github.com/tektoncd/triggers/blob/master/docs/README.md) | [Examples @ HEAD](https://github.com/tektoncd/triggers/blob/master/examples) | [Getting Started @ HEAD](https://github.com/tektoncd/triggers/blob/master/docs/getting-started#getting-started-with-triggers) |
| [v0.1.0](https://github.com/tektoncd/triggers/releases/tag/v0.1.0) | [Docs @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/docs#tekton-triggers) | [Examples @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/examples#examples) | [Getting Started @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/docs/getting-started#getting-started-with-triggers) |
| Version | Docs | Examples | Getting Started |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [HEAD](https://github.com/tektoncd/triggers/blob/master/DEVELOPMENT.md#install-pipeline) | [Docs @ HEAD](https://github.com/tektoncd/triggers/blob/master/docs/README.md) | [Examples @ HEAD](https://github.com/tektoncd/triggers/blob/master/examples) | [Getting Started @ HEAD](https://github.com/tektoncd/triggers/blob/master/docs/getting-started#getting-started-with-triggers) |
| [v0.1.0](https://github.com/tektoncd/triggers/releases/tag/v0.1.0) | [Docs @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/docs#tekton-triggers) | [Examples @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/examples#examples) | [Getting Started @ v0.1.0](https://github.com/tektoncd/triggers/tree/v0.1.0/docs/getting-started#getting-started-with-triggers) |

## Want to contribute

Expand Down
2 changes: 1 addition & 1 deletion code-of-conduct.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
[homepage]: https://www.contributor-covenant.org
10 changes: 9 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Tekton Triggers
Triggers enables users to map fields from an event payload into resource templates. Put another way, this allows events to both model and instantiate themselves as Kubernetes resources. In the case of `tektoncd/pipeline`, this makes it easy to encapsulate configuration into `PipelineRun`s and `PipelineResource`s.

Triggers enables users to map fields from an event payload into resource
templates. Put another way, this allows events to both model and instantiate
themselves as Kubernetes resources. In the case of `tektoncd/pipeline`, this
makes it easy to encapsulate configuration into `PipelineRun`s and
`PipelineResource`s.

![TriggerFlow](../images/TriggerFlow.png)

## Learn More

See the following links for more on each of the resources involved:

- [`TriggerTemplate`](triggertemplates.md)
- [`TriggerBinding`](triggerbindings.md)
- [`EventListener`](eventlisteners.md)

## Getting Started Tasks

- [Create an Ingress on the EventListener Service](create-ingress.yaml)
- [Create a GitHub webhook](create-webhook.yaml)
8 changes: 4 additions & 4 deletions docs/cel_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ headers are also available.
</tr>
</table>

NOTE: The header value is a Go `http.Header`, which is [defined](https://golang.org/pkg/net/http/#Header) as:
NOTE: The header value is a Go `http.Header`, which is
[defined](https://golang.org/pkg/net/http/#Header) as:

```go
type Header map[string][]string
Expand All @@ -54,11 +55,10 @@ type Header map[string][]string
i.e. the header is a mapping of strings, to arrays of strings, see the `match`
function on headers below for an extension that makes looking up headers easier.


### List of extension functions

This lists custom functions that can be used from CEL expressions in the
CEL interceptor.
This lists custom functions that can be used from CEL expressions in the CEL
interceptor.

<table style="width=100%" border="1">
<tr>
Expand Down
39 changes: 20 additions & 19 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resources will be created (or at least attempted) with. The service account must
have the following role bound.

<!-- FILE: examples/role-resources/role.yaml -->

```YAML
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -26,7 +27,6 @@ rules:
verbs: ["create"]
```
Note that currently, JSON is the only accepted MIME type for events.
When an `EventListener` is successfully created, a service is created that
Expand All @@ -53,11 +53,11 @@ make it reachable externally.
By default, EventListeners will attach the following labels automatically to all
resources created:

Name | Description
------------------------ | -----------
tekton.dev/eventlistener | Name of the EventListener that generated the resource.
tekton.dev/trigger | Name of the trigger that generated the resource.
tekton.dev/eventid | UID of the incoming event.
| Name | Description |
| ------------------------ | ------------------------------------------------------ |
| tekton.dev/eventlistener | Name of the EventListener that generated the resource. |
| tekton.dev/trigger | Name of the trigger that generated the resource. |
| tekton.dev/eventid | UID of the incoming event. |

## Event Interceptors

Expand All @@ -66,9 +66,9 @@ modify the behavior or payload of triggers.

Event Interceptors can take several different forms today:

* Webhook Interceptors
* GitHub Interceptors
* GitLab Interceptors
- Webhook Interceptors
- GitHub Interceptors
- GitLab Interceptors

### Webhook Interceptors

Expand Down Expand Up @@ -100,14 +100,16 @@ binding/templating.

To be an Event Interceptor, a Kubernetes object should:

* Be fronted by a regular Kubernetes v1 Service over port 80
* Accept JSON payloads over HTTP
* Return a HTTP 200 OK Status if the EventListener should continue processing the event
* Return a JSON body back. This will be used by the EventListener as the event payload
for any further processing. If the interceptor does not need to modify the body, it can
simply return the body that it received.
- Be fronted by a regular Kubernetes v1 Service over port 80
- Accept JSON payloads over HTTP
- Return a HTTP 200 OK Status if the EventListener should continue processing
the event
- Return a JSON body back. This will be used by the EventListener as the event
payload for any further processing. If the interceptor does not need to modify
the body, it can simply return the body that it received.

<!-- FILE: examples/eventlisteners/eventlistener-interceptor.yaml -->

```YAML
---
apiVersion: tekton.dev/v1alpha1
Expand Down Expand Up @@ -138,7 +140,6 @@ spec:
name: pipeline-template
```


### GitHub Interceptors

GitHub interceptors contain logic to validate and filter webhooks that come from
Expand All @@ -160,6 +161,7 @@ The body/header of the incoming request will be preserved in this interceptor's
response.

<!-- FILE: examples/eventlisteners/github-eventlistener-interceptor.yaml -->

```YAML
---
apiVersion: tekton.dev/v1alpha1
Expand All @@ -184,7 +186,6 @@ spec:
name: pipeline-template
```


### GitLab Interceptors

GitLab interceptors contain logic to validate and filter requests that come from
Expand All @@ -207,6 +208,7 @@ The body/header of the incoming request will be preserved in this interceptor's
response.

<!-- FILE: examples/eventlisteners/gitlab-eventlistener-interceptor.yaml -->

```YAML
---
apiVersion: tekton.dev/v1alpha1
Expand All @@ -231,7 +233,6 @@ spec:
name: pipeline-template
```


### CEL Interceptors

CEL interceptors parse expressions to filter requests based on JSON bodies and
Expand All @@ -244,6 +245,7 @@ The body/header of the incoming request will be preserved in this interceptor's
response.

<!-- FILE: examples/eventlisteners/cel-eventlistener-interceptor.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: EventListener
Expand All @@ -262,6 +264,5 @@ spec:
name: pipeline-template
```


The `expression` must return a `true` value, otherwise the request will be
filtered out.
Loading

0 comments on commit 677627f

Please sign in to comment.