Skip to content

Commit 75344ee

Browse files
afrittolitekton-robot
authored andcommittedOct 14, 2019
Use kubectl create instead of apply
When running YAML E2E tests, use kubectl create instead of apply, so that example can use generateName, which is a best practice for run objects (TaskRun/PipelineRun). Using "create" also exposed name conflicts for several resources all named the same. Luckily the content of those secret was the same, so we had no race condition in the past, but it's best to avoid side effects between tests as much as possible and keep resource names uniques across examples. With this change we start running taskrun tests again, and it turns out the gitlab test is broken because of a broken gitlab URL. Introduce a subfolder for examples that are valid but that we don't want to run in CI because they need some access to a resource which is not available. The Gitlab test has been removed before this was merged, but keeping the no-ci folder anyways as it may be useful for examples that we have no easy way to run in CI. Fixes tektoncd#1397
1 parent e01fe60 commit 75344ee

14 files changed

+40
-35
lines changed
 

‎examples/pipelineruns/no-ci/.keep

Whitespace-only changes.

‎examples/pipelineruns/output-pipelinerun.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: tekton.dev/v1alpha1
22
kind: PipelineResource
33
metadata:
4-
name: skaffold-git
4+
name: skaffold-git-output-pipelinerun
55
spec:
66
type: git
77
params:
@@ -102,4 +102,4 @@ spec:
102102
resources:
103103
- name: source-repo
104104
resourceRef:
105-
name: skaffold-git
105+
name: skaffold-git-output-pipelinerun

‎examples/pipelineruns/pipelinerun.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
apiVersion: rbac.authorization.k8s.io/v1
1717
kind: ClusterRoleBinding
1818
metadata:
19-
name: default-cluster-admin
19+
generateName: default-cluster-admin-
2020
subjects:
2121
- kind: ServiceAccount
2222
name: default
@@ -29,7 +29,7 @@ roleRef:
2929
apiVersion: tekton.dev/v1alpha1
3030
kind: PipelineResource
3131
metadata:
32-
name: skaffold-image-leeroy-web
32+
name: skaffold-image-leeroy-web-pipelinerun
3333
spec:
3434
type: image
3535
params:
@@ -39,7 +39,7 @@ spec:
3939
apiVersion: tekton.dev/v1alpha1
4040
kind: PipelineResource
4141
metadata:
42-
name: skaffold-git
42+
name: skaffold-git-pipelinerun
4343
spec:
4444
type: git
4545
params:
@@ -250,10 +250,10 @@ spec:
250250
resources:
251251
- name: source-repo
252252
resourceRef:
253-
name: skaffold-git
253+
name: skaffold-git-pipelinerun
254254
- name: web-image
255255
resourceRef:
256-
name: skaffold-image-leeroy-web
256+
name: skaffold-image-leeroy-web-pipelinerun
257257
- name: app-image
258258
resourceRef:
259259
name: skaffold-image-leeroy-app

‎examples/taskruns/build-push-kaniko.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: tekton.dev/v1alpha1
22
kind: PipelineResource
33
metadata:
4-
name: skaffold-image-leeroy-web
4+
name: skaffold-image-leeroy-web-build-push-kaniko
55
spec:
66
type: image
77
params:
@@ -11,7 +11,7 @@ spec:
1111
apiVersion: tekton.dev/v1alpha1
1212
kind: PipelineResource
1313
metadata:
14-
name: skaffold-git
14+
name: skaffold-git-build-push-kaniko
1515
spec:
1616
type: git
1717
params:
@@ -54,7 +54,7 @@ spec:
5454
- --dockerfile=$(inputs.params.pathToDockerFile)
5555
- --destination=$(outputs.resources.builtImage.url)
5656
- --context=$(inputs.params.pathToContext)
57-
- --oci-layout-path=/builder/home/image-outputs/builtImage
57+
- --oci-layout-path=/builder/home/image-outputs/builtImage
5858
sidecars:
5959
- image: registry
6060
name: registry
@@ -70,7 +70,7 @@ spec:
7070
resources:
7171
- name: workspace
7272
resourceRef:
73-
name: skaffold-git
73+
name: skaffold-git-build-push-kaniko
7474
params:
7575
- name: pathToDockerFile
7676
value: Dockerfile
@@ -80,4 +80,4 @@ spec:
8080
resources:
8181
- name: builtImage
8282
resourceRef:
83-
name: skaffold-image-leeroy-web
83+
name: skaffold-image-leeroy-web-build-push-kaniko

‎examples/taskruns/configmap.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: config-for-testing
4+
name: config-for-testing-configmaps
55
data:
66
test.data: tasks are my jam
77
---
@@ -22,12 +22,12 @@ spec:
2222
- name: TEST_DATA
2323
valueFrom:
2424
configMapKeyRef:
25-
name: config-for-testing
25+
name: config-for-testing-configmaps
2626
key: test.data
2727
volumeMounts:
2828
- name: config-volume
2929
mountPath: /config
3030
volumes:
3131
- name: config-volume
3232
configMap:
33-
name: config-for-testing
33+
name: config-for-testing-configmaps

‎examples/taskruns/no-ci/.keep

Whitespace-only changes.

‎examples/taskruns/secret-env.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kind: Secret
22
apiVersion: v1
33
metadata:
4-
name: secret-password
4+
name: secret-env-password
55
stringData:
66
ninja: SECRET_PASSWORD
77
---
@@ -22,5 +22,5 @@ spec:
2222
- name: SECRET_PASSWORD
2323
valueFrom:
2424
secretKeyRef:
25-
name: secret-password
25+
name: secret-env-password
2626
key: ninja

‎examples/taskruns/secret-volume-params.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kind: Secret
22
apiVersion: v1
33
metadata:
4-
name: secret-password
4+
name: secret-vol-param-password
55
stringData:
66
ninja: SECRET_PASSWORD
77
---
@@ -15,6 +15,7 @@ spec:
1515
params:
1616
- name: SCNAME
1717
description: Name of secret
18+
type: string
1819
steps:
1920
- image: ubuntu
2021
command:
@@ -33,4 +34,4 @@ spec:
3334
inputs:
3435
params:
3536
- name: SCNAME
36-
value: secret-password
37+
value: secret-vol-param-password

‎examples/taskruns/secret-volume.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kind: Secret
22
apiVersion: v1
33
metadata:
4-
name: secret-password
4+
name: secret-vol-password
55
stringData:
66
ninja: SECRET_PASSWORD
77
---
@@ -25,4 +25,4 @@ spec:
2525
volumes:
2626
- name: secret-volume
2727
secret:
28-
secretName: secret-password
28+
secretName: secret-vol-password

‎examples/taskruns/steptemplate-env-merge.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ spec:
1919
params:
2020
- name: FOO
2121
description: FOO variable
22+
type: string
2223
- name: BAR
2324
description: BAR variable
25+
type: string
2426
- name: FOOBAR
2527
description: FOOBAR variable
2628
default: foobar
29+
type: string
2730
steps:
2831
# Test the environment variables are set in the task
2932
- name: foo

‎examples/taskruns/task-multiple-output-image.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
apiVersion: rbac.authorization.k8s.io/v1
2525
kind: ClusterRoleBinding
2626
metadata:
27-
name: default-cluster-admin
27+
generateName: default-cluster-admin-
2828
subjects:
2929
- kind: ServiceAccount
3030
name: default
@@ -37,7 +37,7 @@ roleRef:
3737
apiVersion: tekton.dev/v1alpha1
3838
kind: PipelineResource
3939
metadata:
40-
name: skaffold-git
40+
name: skaffold-git-multiple-output-image
4141
spec:
4242
type: git
4343
params:
@@ -46,7 +46,7 @@ spec:
4646
- name: url
4747
value: https://github.com/GoogleContainerTools/skaffold
4848
---
49-
# This task is currently hardcoding a index.json file instead of
49+
# This task is currently hardcoding a index.json file instead of
5050
# building an image since kaniko and other easy to use tools don't
5151
# support exporting this file yet
5252
apiVersion: tekton.dev/v1alpha1
@@ -117,7 +117,7 @@ spec:
117117
resources:
118118
- name: sourcerepo
119119
resourceRef:
120-
name: skaffold-git
120+
name: skaffold-git-multiple-output-image
121121
outputs:
122122
resources:
123123
- name: builtImage1

‎examples/taskruns/task-output-image.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: tekton.dev/v1alpha1
22
kind: PipelineResource
33
metadata:
4-
name: skaffold-image-leeroy-web
4+
name: skaffold-image-leeroy-web-output-image
55
spec:
66
type: image
77
params:
@@ -14,7 +14,7 @@ spec:
1414
apiVersion: rbac.authorization.k8s.io/v1
1515
kind: ClusterRoleBinding
1616
metadata:
17-
name: default-cluster-admin
17+
generateName: default-cluster-admin-
1818
subjects:
1919
- kind: ServiceAccount
2020
name: default
@@ -27,7 +27,7 @@ roleRef:
2727
apiVersion: tekton.dev/v1alpha1
2828
kind: PipelineResource
2929
metadata:
30-
name: skaffold-git
30+
name: skaffold-git-output-image
3131
spec:
3232
type: git
3333
params:
@@ -36,7 +36,7 @@ spec:
3636
- name: url
3737
value: https://github.com/GoogleContainerTools/skaffold
3838
---
39-
# This task is currently hardcoding a index.json file instead of
39+
# This task is currently hardcoding a index.json file instead of
4040
# building an image since kaniko and other easy to use tools don't
4141
# support exporting this file yet
4242
apiVersion: tekton.dev/v1alpha1
@@ -95,9 +95,9 @@ spec:
9595
resources:
9696
- name: sourcerepo
9797
resourceRef:
98-
name: skaffold-git
98+
name: skaffold-git-output-image
9999
outputs:
100100
resources:
101101
- name: builtImage
102102
resourceRef:
103-
name: skaffold-image-leeroy-web
103+
name: skaffold-image-leeroy-web-output-image

‎examples/taskruns/task-volume-args.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: config-for-testing
4+
name: config-for-testing-volume-args
55
data:
66
test.data: tasks are my jam
77
---
@@ -15,6 +15,7 @@ spec:
1515
params:
1616
- name: CFGNAME
1717
description: Name of config map
18+
type: string
1819
steps:
1920
- name: read
2021
image: ubuntu
@@ -30,4 +31,4 @@ spec:
3031
inputs:
3132
params:
3233
- name: CFGNAME
33-
value: config-for-testing
34+
value: config-for-testing-volume-args

‎test/e2e-common.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ function create_resources() {
9494
echo ">> Creating resources ${resource}"
9595

9696
# Applying the resources, either *taskruns or * *pipelineruns
97-
for file in $(find ${REPO_ROOT_DIR}/examples/${resource}s/ -name *.yaml | sort); do
98-
perl -p -e 's/gcr.io\/christiewilson-catfactory/$ENV{KO_DOCKER_REPO}/g' ${file} | ko apply -f - || return 1
97+
for file in $(find ${REPO_ROOT_DIR}/examples/${resource}s/ -name *.yaml -not -path "${REPO_ROOT_DIR}/examples/${resource}s/no-ci/*" | sort); do
98+
perl -p -e 's/gcr.io\/christiewilson-catfactory/$ENV{KO_DOCKER_REPO}/g' ${file} | ko create -f - || return 1
9999
done
100100
}
101101

0 commit comments

Comments
 (0)
Please sign in to comment.