forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptional-resources.yaml
133 lines (128 loc) · 3.21 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
131
132
133
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: task-check-optional-resources
spec:
inputs:
resources:
- name: git-repo
type: git
description: "The input is code from a git repository"
optional: true
params:
- name: filename
type: string
default: "README.md"
outputs:
resources:
- 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 $(inputs.resources.git-repo.path) ]; then
echo "Git repo was cloned at $(inputs.resources.git-repo.path)"
if [ -f $(inputs.resources.git-repo.path)/$(inputs.params.filename) ]; then
echo "$(inputs.params.filename) does exist at $(inputs.resources.git-repo.path)"
else
echo "$(inputs.params.filename) does not exist at $(inputs.resources.git-repo.path)"
fi
else
echo "Git repo was not cloned at $(inputs.resources.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/v1alpha1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-with-resources
spec:
inputs:
resources:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
params:
- name: filename
value: "README.md"
outputs:
resources:
- name: optionalimage
resourceSpec:
type: image
params:
- name: url
value: gcr.io/foo/bar
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-invalid-filename
spec:
inputs:
resources:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
params:
- name: filename
value: "invalid.md"
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-without-resources
spec:
inputs:
params:
- name: filename
value: "README.md"
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: demo-optional-inputs-resources-without-resources-and-params
spec:
taskRef:
name: task-check-optional-resources
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: demo-optional-outputs-resources-with-input-resources
spec:
inputs:
resources:
- name: git-repo
resourceSpec:
type: git
params:
- name: url
value: https://github.com/tektoncd/pipeline.git
params:
- name: filename
value: "README.md"
taskRef:
name: task-check-optional-resources
---