forked from tektoncd/triggers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples/tests. Use examples as part of documentation. Add utilit…
…y/test to keep docs fresh
- Loading branch information
1 parent
a771c06
commit a7fc3da
Showing
12 changed files
with
235 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
# EventListener | ||
`EventListeners` encapsulate one or more `TriggerBindings` into an addressable endpoint, which is where webhooks/events are directed. When an `EventListener` is successfully created, a service is created that references a listener pod. This listener pod accepts the incoming events and does what has been specified in the corresponding `TriggerBindings`/`TriggerTemplates`. | ||
|
||
<!-- FILE: examples/eventlisteners/eventlistener.yaml --> | ||
```YAML | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: EventListener | ||
metadata: | ||
name: simple-listener | ||
name: listener | ||
namespace: tekton-pipelines | ||
spec: | ||
triggerbindingrefs: | ||
- simple-pipeline-binding | ||
``` | ||
- name: pipeline-binding | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: EventListener | ||
metadata: | ||
name: listener | ||
namespace: tekton-pipelines | ||
spec: | ||
triggerbindingrefs: | ||
- name: pipeline-binding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: TriggerBinding | ||
metadata: | ||
name: pipeline-binding | ||
namespace: tekton-pipelines | ||
spec: | ||
templatebindings: | ||
- templateref: | ||
name: pipeline-template | ||
params: | ||
- name: gitrevision | ||
value: $(event.head_commit.id) | ||
- name: gitrepositoryurl | ||
value: $(event.repository.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: TriggerTemplate | ||
metadata: | ||
name: pipeline-template | ||
namespace: tekton-pipelines | ||
spec: | ||
params: | ||
- name: gitrevision | ||
description: The git revision | ||
default: master | ||
- name: gitrepositoryurl | ||
description: The git repository url | ||
- name: namespace | ||
description: The namespace to create the resources | ||
resourcetemplates: | ||
- apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineResource | ||
metadata: | ||
name: git-source | ||
namespace: $(params.namespace) | ||
labels: | ||
triggertemplated: true | ||
spec: | ||
type: git | ||
params: | ||
- name: revision | ||
value: $(params.gitrevision) | ||
- name: url | ||
value: $(params.gitrepositoryurl) | ||
- apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: simple-pipeline-run | ||
namespace: default | ||
labels: | ||
triggertemplated: true | ||
spec: | ||
pipelineRef: | ||
name: simple-pipeline | ||
trigger: | ||
type: event | ||
resources: | ||
- name: git-source | ||
resourceRef: | ||
name: git-source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
source $(dirname $0)/../vendor/github.com/tektoncd/plumbing/scripts/library.sh | ||
cd ${REPO_ROOT_DIR} | ||
|
||
# Whether this script is being used for validation or not | ||
DIFF= | ||
# Syntax format for code fences | ||
SYNTAX="YAML" | ||
CODE_FENCE='^```' | ||
# Comment that will specify the file to embed within $SYNTAX code fence | ||
COMMENT='<!-- *FILE: *(.*) *-->' | ||
EMPTY='^[[:space:]]*$' | ||
|
||
# Parse flags | ||
while getopts ":d" opt; do | ||
case ${opt} in | ||
d ) | ||
DIFF="true" | ||
;; | ||
* ) | ||
echo "Invalid Option: -$OPTARG" 1>&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND -1)) | ||
|
||
doc_files="$(find docs -name "*.md")" | ||
for file in ${doc_files};do | ||
new_file="${file%/*}/updated-${file##*/}" | ||
> ${new_file} | ||
fenced="false" | ||
# Read each markdown file for replacements | ||
while IFS= read -r line; do | ||
# File has been embedded | ||
if [[ ${fenced} == "maybe" ]];then | ||
# Look for proceeding codefence | ||
if [[ ${line} =~ ${CODE_FENCE} ]];then | ||
fenced="true" | ||
continue | ||
fi | ||
# If a non-empty line is deteced | ||
if [[ ! ${line} =~ ${EMPTY} ]];then | ||
fenced="false" | ||
fi | ||
fi | ||
# Turn off code fencing | ||
if [[ ${fenced} == "true" ]];then | ||
if [[ ${line} =~ ${CODE_FENCE} ]];then | ||
fenced="false" | ||
continue | ||
fi | ||
fi | ||
# Write to replacement file | ||
if [[ ${fenced} != "true" ]];then | ||
# Copy line | ||
echo "${line}" >> ${new_file} | ||
# Inline file | ||
if [[ "$line" =~ ${COMMENT} ]];then | ||
echo '```'$SYNTAX >> ${new_file} | ||
cat ${BASH_REMATCH[1]} >> ${new_file} | ||
echo '```' >> ${new_file} | ||
fenced="maybe" | ||
fi | ||
fi | ||
done < "${file}" | ||
|
||
if [[ ${DIFF} == "true" ]];then | ||
# Check if up to date | ||
set +o errexit | ||
diff ${file} ${new_file} | ||
if [[ $? != 0 ]];then | ||
echo 'Run `./hack/update-docs.sh` to update the docs' | ||
exit 1 | ||
fi | ||
else | ||
# Overwrite file | ||
rm ${file} | ||
mv ${new_file} ${file} | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
source $(dirname $0)/e2e-common.sh | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
for op in apply delete;do | ||
# Apply TriggerTemplates | ||
for file in $(find ${REPO_ROOT_DIR}/examples/triggertemplates/ -name *.yaml | sort); do | ||
kubectl ${op} -f ${file} | ||
done | ||
|
||
# Apply TriggerBindings | ||
for file in $(find ${REPO_ROOT_DIR}/examples/triggerbindings/ -name *.yaml | sort); do | ||
kubectl ${op} -f ${file} | ||
done | ||
|
||
# Apply EventListeners | ||
for file in $(find ${REPO_ROOT_DIR}/examples/eventlisteners/ -name *.yaml | sort); do | ||
kubectl ${op} -f ${file} | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters