Skip to content

Commit

Permalink
V1 CRD release
Browse files Browse the repository at this point in the history
This commit adds the examples test for the v1 CRD. It sets the `served` fields of the CRDs to true.
  • Loading branch information
JeromeJu committed Sep 30, 2022
1 parent 4b53ae5 commit a636821
Show file tree
Hide file tree
Showing 86 changed files with 4,830 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/300-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
# See issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
- name: v1
served: false
served: true
storage: false
schema:
openAPIV3Schema:
Expand Down
2 changes: 1 addition & 1 deletion config/300-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
subresources:
status: {}
- name: v1
served: false
served: true
storage: false
schema:
openAPIV3Schema:
Expand Down
2 changes: 1 addition & 1 deletion config/300-task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
subresources:
status: {}
- name: v1
served: false
served: true
storage: false
schema:
openAPIV3Schema:
Expand Down
2 changes: 1 addition & 1 deletion config/300-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
subresources:
status: {}
- name: v1
served: false
served: true
storage: false
schema:
openAPIV3Schema:
Expand Down
File renamed without changes.
95 changes: 95 additions & 0 deletions examples/v1/pipelineruns/4808-regression.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: print-result
spec:
description: >-
Prints a result from another task
params:
- name: TO_PRINT
type: string
steps:
- name: print-result
image: bash:latest
env:
- name: PARAM_TO_PRINT
value: $(params.TO_PRINT)
script: |
#!/usr/bin/env bash
set -e
echo $PARAM_TO_PRINT
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: generate-result
spec:
description: >-
Creates strings of length based on parameters and puts them into results fields
params:
- name: STRING_LENGTH
description: Length of the string to create
- name: STRING_CHAR
description: Char to use when creating string
type: string
default: '.'
results:
- name: RESULT_STRING
description: A result string
steps:
- name: gen-result
image: bash:latest
env:
- name: PARAM_STRING_LENGTH
value: $(params.STRING_LENGTH)
- name: PARAM_STRING_CHAR
value: $(params.STRING_CHAR)
script: |
#!/usr/bin/env bash
set -e
len=$PARAM_STRING_LENGTH
ch=$PARAM_STRING_CHAR
printf '%*s' "$len" | tr ' ' "$ch" >> $(results.RESULT_STRING.path)
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: result-test
spec:
description: >-
Generate a result of a certain length in a task and print the result in another task
params:
- name: RESULT_STRING_LENGTH
description: Length of string to generate for generate-result task
- name: RESULT_STRING_CHAR
description: Char to repeat in result string
default: '.'
tasks:
- name: generate-result
params:
- name: STRING_LENGTH
value: $(params.RESULT_STRING_LENGTH)
- name: STRING_CHAR
value: $(params.RESULT_STRING_CHAR)
taskRef:
kind: Task
name: generate-result
- name: print-result
params:
- name: TO_PRINT
value: $(tasks.generate-result.results.RESULT_STRING)
taskRef:
kind: Task
name: print-result
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: result-test-run
spec:
pipelineRef:
name: result-test
params:
- name: RESULT_STRING_LENGTH
value: "3000"
121 changes: 121 additions & 0 deletions examples/v1/pipelineruns/ignore-step-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
kind: PipelineRun
apiVersion: tekton.dev/v1
metadata:
generateName: pipelinerun-with-failing-step-
spec:
taskRunTemplate:
serviceAccountName: 'default'
params:
- name: CONTINUE
value: "continue"
pipelineSpec:
params:
- name: CONTINUE
tasks:
- name: task1
params:
- name: CONTINUE
value: "$(params.CONTINUE)"
taskSpec:
params:
- name: CONTINUE
steps:
# not really doing anything here, just a hurdle to test the "ignore step error"
- image: alpine
onError: $(params.CONTINUE)
name: exit-with-1
script: |
exit 1
# initialize a task result which will be validated by the next task
- image: alpine
name: write-a-result
onError: continue
script: |
echo -n 123 | tee $(results.task1-result.path)
exit 11
results:
- name: task1-result
description: result of a task1
- name: task2
runAfter: ["task1"]
params:
- name: task1-result
value: $(tasks.task1.results.task1-result)
taskSpec:
params:
- name: task1-result
steps:
# again, not really doing anything here, just a hurdle to test the "ignore step error"
- image: alpine
onError: continue
name: exit-with-255
script: |
exit 255
# verify that the task result was produced by the first task, fail if the result does not match
- image: alpine
name: verify-a-task-result
script: |
ls /tekton/results/
if [ $(params.task1-result) == 123 ]; then
echo "Yay! the task result matches which was initialized in the previous task while ignoring the step error"
else
echo "the task result does not match."
exit 1
fi
# the last step of a task and one more hurdle
- image: alpine
name: exit-with-20
onError: continue
script: |
exit 20
---

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: pipelinerun-with-failing-step-and-ws-
spec:
workspaces:
- name: ws
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 16Mi
pipelineSpec:
tasks:
- name: writer
taskSpec:
steps:
- name: write
image: alpine
onError: continue
script: |
ls -1 /tekton/run/
echo bar > $(workspaces.task-ws.path)/foo
exit 1
workspaces:
- name: task-ws
workspaces:
- name: task-ws
workspace: ws
- name: reader
runAfter:
- writer
taskSpec:
steps:
- name: read
image: alpine
onError: continue
script: |
cat $(workspaces.myws.path)/foo | grep bar
exit 1
workspaces:
- name: myws
workspaces:
- name: myws
workspace: ws
workspaces:
- name: ws
131 changes: 131 additions & 0 deletions examples/v1/pipelineruns/mapping-workspaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# In this contrived example 3 different kinds of workspace volume are used to thread
# data through a pipeline's tasks.
# 1. A ConfigMap is used as source of recipe data.
# 2. A Secret is used to store a password.
# 3. A PVC is used to share data from one task to the next.
#
# The end result is a pipeline that first checks if the password is correct and, if so,
# copies data out of a recipe store onto a shared volume. The recipe data is then read
# by a subsequent task and printed to screen.
apiVersion: v1
kind: ConfigMap
metadata:
name: sensitive-recipe-storage
data:
brownies: |
1. Heat oven to 325 degrees F
2. Melt 1/2 cup butter w/ 1/2 cup cocoa, stirring smooth.
3. Remove from heat, allow to cool for a few minutes.
4. Transfer to bowl.
5. Whisk in 2 eggs, one at a time.
6. Stir in vanilla.
7. Separately combine 1 cup sugar, 1/4 cup flour, 1 cup chopped
walnuts and pinch of salt
8. Combine mixtures.
9. Bake in greased pan for 30 minutes. Watch carefully for
appropriate level of gooeyness.
---
apiVersion: v1
kind: Secret
metadata:
name: secret-password
type: Opaque
data:
password: aHVudGVyMg==
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-task-storage
spec:
resources:
requests:
storage: 16Mi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: fetch-secure-data
spec:
workspaces:
- name: password-vault
- name: recipe-store
- name: shared-data
steps:
- name: fetch-and-write
image: ubuntu
script: |
if [ "hunter2" = "$(cat $(workspaces.password-vault.path)/password)" ]; then
cp $(workspaces.recipe-store.path)/recipe.txt $(workspaces.shared-data.path)
else
echo "wrong password!"
exit 1
fi
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: print-data
spec:
workspaces:
- name: shared-data
readOnly: true
params:
- name: filename
steps:
- name: print-secrets
image: ubuntu
script: cat $(workspaces.shared-data.path)/$(params.filename)
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: fetch-and-print-recipe
spec:
workspaces:
- name: password-vault
- name: recipe-store
- name: shared-data
tasks:
- name: fetch-the-recipe
taskRef:
name: fetch-secure-data
workspaces:
- name: password-vault
- name: recipe-store
- name: shared-data
- name: print-the-recipe
taskRef:
name: print-data
# Note: this is currently required to ensure order of write / read on PVC is correct.
runAfter:
- fetch-the-recipe
params:
- name: filename
value: recipe.txt
workspaces:
- name: shared-data
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: recipe-time-
spec:
pipelineRef:
name: fetch-and-print-recipe
workspaces:
- name: password-vault
secret:
secretName: secret-password
- name: recipe-store
configMap:
name: sensitive-recipe-storage
items:
- key: brownies
path: recipe.txt
- name: shared-data
persistentVolumeClaim:
claimName: shared-task-storage
Empty file.
Loading

0 comments on commit a636821

Please sign in to comment.