-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathtest-publish-index-image.yaml
More file actions
236 lines (224 loc) · 8.49 KB
/
Copy pathtest-publish-index-image.yaml
File metadata and controls
236 lines (224 loc) · 8.49 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-publish-index-image
spec:
description: Test creating a internal request to publish an image
params:
- name: ociStorage
description: The OCI repository where the Trusted Artifacts are stored.
type: string
- name: ociArtifactExpiresAfter
description: Expiration date for the trusted artifacts created in the
OCI repository. An empty string means the artifacts do not expire.
type: string
default: "1d"
- name: orasOptions
description: oras options to pass to Trusted Artifacts calls
type: string
default: "--insecure"
- name: trustedArtifactsDebug
description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable.
type: string
default: ""
- name: dataDir
description: The location where data will be stored
type: string
tasks:
- name: setup
taskSpec:
results:
- name: sourceDataArtifact
type: string
volumes:
- name: workdir
emptyDir: {}
stepTemplate:
volumeMounts:
- mountPath: /var/workdir
name: workdir
env:
- name: IMAGE_EXPIRES_AFTER
value: $(params.ociArtifactExpiresAfter)
- name: "ORAS_OPTIONS"
value: "$(params.orasOptions)"
- name: "DEBUG"
value: "$(params.trustedArtifactsDebug)"
steps:
- name: setup-values
image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3
script: |
#!/usr/bin/env sh
set -eux
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
cat > "$(params.dataDir)/$(context.pipelineRun.uid)/data.json" << EOF
{
"fbc": {
"publishingCredentials": "test-credentials"
}
}
EOF
cat > "$(params.dataDir)/internal-requests-results.json" << EOF
{
"index_image": {
"target_index": "quay.io/scoheb/fbc-target-index-testing:v4.12"
},
"components": [
{
"fbc_fragment": "registry.io/image0@sha256:0000",
"target_index": "quay.io/scoheb/fbc-target-index-testing:v4.12",
"ocp_version": "v4.12",
"index_image": "redhat.com/rh-stage/iib:01",
"index_image_resolved": "redhat.com/rh-stage/iib@sha256:abcdefghijk",
"image_digests": [
"quay.io/a",
"quay.io/b"
],
"completion_time": "2023-03-06T16:39:11.314092Z",
"iibLog": "Dummy IIB Log"
}
]
}
EOF
- name: create-trusted-artifact
ref:
name: create-trusted-artifact
params:
- name: ociStorage
value: $(params.ociStorage)
- name: workDir
value: $(params.dataDir)
- name: sourceDataArtifact
value: $(results.sourceDataArtifact.path)
- name: run-task
taskRef:
name: publish-index-image
params:
- name: buildTimestamp
value: 11111111111
- name: internalRequestResultsFile
value: "internal-requests-results.json"
- name: retries
value: 2
- name: pipelineRunUid
value: $(context.pipelineRun.uid)
- name: dataPath
value: $(context.pipelineRun.uid)/data.json
- name: ociStorage
value: $(params.ociStorage)
- name: orasOptions
value: $(params.orasOptions)
- name: sourceDataArtifact
value: "$(tasks.setup.results.sourceDataArtifact)=$(params.dataDir)"
- name: dataDir
value: $(params.dataDir)
- name: trustedArtifactsDebug
value: $(params.trustedArtifactsDebug)
- name: taskGitUrl
value: "http://localhost"
- name: taskGitRevision
value: "main"
runAfter:
- setup
- name: check-result
params:
- name: sourceDataArtifact
value: "$(tasks.run-task.results.sourceDataArtifact)=$(params.dataDir)"
- name: dataDir
value: $(params.dataDir)
runAfter:
- run-task
taskSpec:
params:
- name: sourceDataArtifact
type: string
- name: dataDir
type: string
volumes:
- name: workdir
emptyDir: {}
stepTemplate:
volumeMounts:
- mountPath: /var/workdir
name: workdir
env:
- name: IMAGE_EXPIRES_AFTER
value: $(params.ociArtifactExpiresAfter)
- name: "ORAS_OPTIONS"
value: "$(params.orasOptions)"
- name: "DEBUG"
value: "$(params.trustedArtifactsDebug)"
steps:
- name: use-trusted-artifact
ref:
name: use-trusted-artifact
params:
- name: workDir
value: $(params.dataDir)
- name: sourceDataArtifact
value: $(params.sourceDataArtifact)
- name: check-result
image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3
script: |
#!/usr/bin/env bash
set -eux
internalRequests=$(kubectl get internalrequest --sort-by=.metadata.creationTimestamp --no-headers \
-o json | jq '.items')
irIndex=$(jq '. | length' <<< "${internalRequests}")
if [ "${irIndex}" -ne 2 ]; then
echo "Too many internalrequests found. Should be 2"
exit 1
fi
for((i=0; i<irIndex; i++)); do
pipeline=$(jq -r ".[$i] | .spec.pipeline.pipelineRef.params[2].value" <<< "${internalRequests}")
params=$(jq -r ".[$i] | .spec.params" <<< "${internalRequests}")
if [ "$pipeline" != \
"pipelines/internal/publish-index-image-pipeline/publish-index-image-pipeline.yaml" ]; then
echo "pipeline does not match"
exit 1
fi
if [ "$(jq -r '.retries' <<< "${params}")" != "2" ]; then
echo "number of retries does not match"
exit 1
fi
if [ "$(jq -r '.sourceIndex' <<< "${params}")" != "redhat.com/rh-stage/iib:01" ]; then
echo "sourceIndex image does not match"
exit 1
fi
targetIndex=$(jq -r '.targetIndex' <<< "${params}")
if [ $i = 0 ]; then
if [ "$targetIndex" != "quay.io/scoheb/fbc-target-index-testing:v4.12" ]; then
echo "targetIndex image does not match"
exit 1
fi
else
expectedTargetIndex="quay.io/scoheb/fbc-target-index-testing:v4.12-2023-03-06T16:39:11.314092Z"
if [ "$targetIndex" != "$expectedTargetIndex" ]; then
echo "targetIndex image does not match"
exit 1
fi
fi
if [ "$(jq -r '.targetOcpVersion' <<< "${params}")" != "v4.12" ]; then
echo "targetOcpVersion does not match"
exit 1
fi
if [ "$(jq -r '.taskGitUrl' <<< "${params}")" != "http://localhost" ]; then
echo "taskGitUrl image does not match"
exit 1
fi
if [ "$(jq -r '.taskGitRevision' <<< "${params}")" != "main" ]; then
echo "taskGitRevision image does not match"
exit 1
fi
done
finally:
- name: cleanup
taskSpec:
steps:
- name: delete-crs
image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3
script: |
#!/usr/bin/env sh
set -eux
kubectl delete internalrequests --all