forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptional-resources.yaml
130 lines (125 loc) · 3.12 KB
/
optional-resources.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task-check-optional-resources
spec:
params:
- name: filename
type: string
default: "README.md"
resources:
inputs:
- name: git-repo
type: git
description: "The input is code from a git repository"
optional: true
outputs:
- name: optionalimage
type: image
description: "The output is a Docker image"
optional: true
steps:
- name: check-git-repo
image: ubuntu
script: |
#!/usr/bin/env bash
if [ -d $(resources.inputs.git-repo.path) ]; then
echo "Git repo was cloned at $(resources.inputs.git-repo.path)"
if [ -f $(resources.inputs.git-repo.path)/$(inputs.params.filename) ]; then
echo "$(inputs.params.filename) does exist at $(resources.inputs.git-repo.path)"
else
echo "$(inputs.params.filename) does not exist at $(resources.inputs.git-repo.path)"
fi
else
echo "Git repo was not cloned at $(resources.inputs.git-repo.path)"
fi
if [ "$(outputs.resources.optionalimage.url)" == "" ]; then
echo "Image URL: $(outputs.resources.optionalimage.url)"
else
echo "No image URL specified."
fi
echo "Yay, Input and Output Resources can be Optional!"
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-with-resources
spec:
params:
- name: filename
value: "README.md"
resources:
inputs:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
outputs:
- name: optionalimage
resourceSpec:
type: image
params:
- name: url
value: gcr.io/foo/bar
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-invalid-filename
spec:
params:
- name: filename
value: "invalid.md"
resources:
inputs:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-without-resources
spec:
params:
- name: filename
value: "README.md"
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-without-resources-and-params
spec:
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: demo-optional-outputs-resources-with-input-resources
spec:
params:
- name: filename
value: "README.md"
resources:
inputs:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
taskRef:
name: task-check-optional-resources
---