forked from konflux-ci/release-service-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-create-pyxis-image-mixed-helm-containers.yaml
More file actions
263 lines (250 loc) · 9.65 KB
/
Copy pathtest-create-pyxis-image-mixed-helm-containers.yaml
File metadata and controls
263 lines (250 loc) · 9.65 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-create-pyxis-image-mixed-helm-containers
spec:
description: |
Run the create-pyxis-image task with a snapshot containing both Helm charts and container images.
Verify that Helm charts are skipped and only container images are processed.
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:02a8ddcd16113371a255fd1ef0a196399d300162
script: |
#!/usr/bin/env bash
set -eux
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
cat > "$(params.dataDir)/$(context.pipelineRun.uid)/mydata.json" << EOF
{
"pyxis": {
"server": "stage",
"certified": false,
"secret": "pyxis"
}
}
EOF
cat > "$(params.dataDir)/$(context.pipelineRun.uid)/mapped_snapshot.json" << EOF
{
"application": "myapp",
"components": [
{
"name": "web-frontend",
"containerImage": "registry.io/web-frontend@sha256:webdigest",
"repositories": [
{
"url": "registry.io/web-frontend",
"tags": ["1.0", "latest"]
}
]
},
{
"name": "helm-chart",
"containerImage": "registry.io/helm-chart@sha256:helmdigest",
"repositories": [
{
"url": "registry.io/helm-chart",
"tags": ["1.0", "latest"]
}
]
},
{
"name": "api-backend",
"containerImage": "registry.io/api-backend@sha256:apidigest",
"repositories": [
{
"url": "registry.io/api-backend",
"tags": ["1.0", "latest"]
}
]
},
{
"name": "database",
"containerImage": "registry.io/database@sha256:dbdigest",
"repositories": [
{
"url": "registry.io/database",
"tags": ["1.0", "latest"]
}
]
}
]
}
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: create-pyxis-image
params:
- name: pyxisSecret
value: test-create-pyxis-image-cert
- name: server
value: stage
- name: snapshotPath
value: $(context.pipelineRun.uid)/mapped_snapshot.json
- name: dataPath
value: $(context.pipelineRun.uid)/mydata.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: pyxisDataPath
value: $(tasks.run-task.results.pyxisDataPath)
- name: sourceDataArtifact
value: "$(tasks.run-task.results.sourceDataArtifact)=$(params.dataDir)"
- name: dataDir
value: $(params.dataDir)
taskSpec:
params:
- name: dataDir
description: The location where data will be stored
type: string
- name: pyxisDataPath
type: string
- 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: 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:02a8ddcd16113371a255fd1ef0a196399d300162
script: |
#!/usr/bin/env bash
set -eux
# Verify pyxis.json structure
pyxis_file="$(params.dataDir)/$(params.pyxisDataPath)"
echo "Contents of pyxis.json:"
cat "$pyxis_file"
# Verify we have the expected number of components (3 containers, Helm chart filtered out)
component_count=$(jq '.components | length' "$pyxis_file")
if [ "$component_count" != "3" ]; then
echo "Error: Expected 3 components in pyxis.json (only container images), but got $component_count"
exit 1
fi
# Test downstream consumption pattern used by push-rpm-data-to-pyxis task
if ! unique_images_result=$(jq '
# This is the exact processing from push-rpm-data-to-pyxis.yaml line 132
[.components[] as $c | $c.pyxisImages[] | {
imageId: .imageId,
containerImage: $c.containerImage,
pyxisImage: .
}]' "$pyxis_file"); then
echo "Error: Downstream consumption pattern failed"
exit 1
fi
# Verify downstream processing produces expected results
image_count=$(echo "$unique_images_result" | jq '. | length')
if [ "$image_count" != "3" ]; then
echo "Error: Expected 3 pyxis images from downstream processing, but got $image_count"
exit 1
fi
echo "SUCCESS: Downstream consumption pattern works correctly"
# Verify that all processed components are container images (not Helm charts)
# by checking that each component has the expected containerImage field and pyxisImages
processed_components=$(jq -r '.components[] | .containerImage' "$pyxis_file")
# Verify we have the expected container images (but not the helm chart)
if ! echo "$processed_components" | grep -q "web-frontend"; then
echo Error: web-frontend container image should be processed
exit 1
fi
if ! echo "$processed_components" | grep -q "api-backend"; then
echo Error: api-backend container image should be processed
exit 1
fi
if ! echo "$processed_components" | grep -q "database"; then
echo Error: database container image should be processed
exit 1
fi
# Verify helm-chart was NOT processed
if echo "$processed_components" | grep -q "helm-chart"; then
echo Error: helm-chart should NOT be processed \(should be skipped\)
exit 1
fi
echo "SUCCESS: Mixed Helm + container images handled correctly"
echo " - Helm chart was skipped"
echo " - All 3 container images were processed"
echo " - Downstream consumption patterns work correctly"
runAfter:
- run-task