Skip to content

Commit 7f43898

Browse files
committed
feat(RELEASE-1614): ta in collect-marketpl..params
- Enable trusted artifacts in collect-marketplacesvm-params Signed-off-by: Scott Hebert <[email protected]>
1 parent 9d58a24 commit 7f43898

6 files changed

+549
-7
lines changed

tasks/managed/collect-marketplacesvm-params/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Tekton task that collects the secret for the cloud marketplaces from the data fi
44

55
## Parameters
66

7-
| Name | Description | Optional | Default value |
8-
|--------------|------------------------------------------------------------------|----------|---------------|
9-
| dataPath | Path to the merged data JSON file generated by collect-data task | No | - |
7+
| Name | Description | Optional | Default value |
8+
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------|----------|---------------|
9+
| dataPath | Path to the merged data JSON file generated by collect-data task | No | - |
10+
| ociStorage | The OCI repository where the Trusted Artifacts are stored. | No | - |
11+
| ociArtifactExpiresAfter | Expiration date for the trusted artifacts created in the OCI repository. An empty string means the artifacts do not expire. | Yes | "" |
12+
| orasOptions | oras options to pass to Trusted Artifacts calls | Yes | "" |
13+
| sourceDataArtifact | The Trusted Artifact URI pointing to the artifact with the application snapshot spec and the release data | No | - |
14+
| dataDir | The location where data will be stored | No | - |
15+
| trustedArtifactsDebug | Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable. | Yes | "" |
16+
| taskGitUrl | The url to the git repo where the release-service-catalog tasks to be used are stored | No | - |
17+
| taskGitRevision | The revision in the taskGitUrl repo to be used | No | - |
18+

tasks/managed/collect-marketplacesvm-params/collect-marketplacesvm-params.yaml

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,37 @@ spec:
1313
- name: dataPath
1414
type: string
1515
description: Path to the merged data JSON file generated by collect-data task
16+
- name: ociStorage
17+
type: string
18+
description: The OCI repository where the Trusted Artifacts are stored.
19+
- name: ociArtifactExpiresAfter
20+
type: string
21+
description: >
22+
Expiration date for the trusted artifacts created in the OCI repository.
23+
An empty string means the artifacts do not expire.
24+
The format is YYYY-MM-DD.
25+
default: ""
26+
- name: orasOptions
27+
type: string
28+
description: oras options to pass to Trusted Artifacts calls
29+
default: ""
30+
- name: sourceDataArtifact
31+
type: string
32+
description: >
33+
The Trusted Artifact URI pointing to the artifact with the application snapshot spec and the release data.
34+
- name: dataDir
35+
type: string
36+
description: The location where data will be stored
37+
- name: trustedArtifactsDebug
38+
type: string
39+
description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable.
40+
default: ""
41+
- name: taskGitUrl
42+
type: string
43+
description: The url to the git repo where the release-service-catalog tasks to be used are stored
44+
- name: taskGitRevision
45+
type: string
46+
description: The revision in the taskGitUrl repo to be used
1647
workspaces:
1748
- name: data
1849
description: The workspace where the data json file resides
@@ -23,10 +54,59 @@ spec:
2354
- name: prePush
2455
type: string
2556
description: "Whether perform a pre-push (true) or not (false). When true it will not publish PROD."
57+
- name: sourceDataArtifact
58+
type: string
59+
description: >
60+
The Trusted Artifact URI pointing to the artifact with the application snapshot spec and the release data.
61+
volumes:
62+
- name: workdir
63+
emptyDir: {}
64+
stepTemplate:
65+
volumeMounts:
66+
- mountPath: /var/workdir
67+
name: workdir
68+
env:
69+
- name: IMAGE_EXPIRES_AFTER
70+
value: $(params.ociArtifactExpiresAfter)
71+
- name: "ORAS_OPTIONS"
72+
value: "$(params.orasOptions)"
73+
- name: "DEBUG"
74+
value: "$(params.trustedArtifactsDebug)"
2675
steps:
76+
- name: skip-trusted-artifact-operations
77+
ref:
78+
resolver: git
79+
params:
80+
- name: url
81+
value: $(params.taskGitUrl)
82+
- name: revision
83+
value: $(params.taskGitRevision)
84+
- name: pathInRepo
85+
value: stepactions/skip-trusted-artifact-operations/skip-trusted-artifact-operations.yaml
86+
params:
87+
- name: ociStorage
88+
value: $(params.ociStorage)
89+
- name: workDir
90+
value: $(params.dataDir)
91+
- name: use-trusted-artifact
92+
ref:
93+
resolver: git
94+
params:
95+
- name: url
96+
value: $(params.taskGitUrl)
97+
- name: revision
98+
value: $(params.taskGitRevision)
99+
- name: pathInRepo
100+
value: stepactions/use-trusted-artifact/use-trusted-artifact.yaml
101+
params:
102+
- name: workDir
103+
value: $(params.dataDir)
104+
- name: sourceDataArtifact
105+
value: $(params.sourceDataArtifact)
27106
- name: collect-marketplacesvm-params
28107
image:
29108
quay.io/konflux-ci/release-service-utils:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
109+
workingDir: $(params.dataDir)
30110
computeResources:
31111
limits:
32112
memory: 128Mi
@@ -37,7 +117,7 @@ spec:
37117
#!/usr/bin/env bash
38118
set -eux
39119
40-
DATA_FILE="$(workspaces.data.path)/$(params.dataPath)"
120+
DATA_FILE="$(params.dataDir)/$(params.dataPath)"
41121
if [ ! -f "${DATA_FILE}" ] ; then
42122
echo "No valid data file was provided."
43123
exit 1
@@ -50,3 +130,35 @@ spec:
50130
51131
jq -j '.mapping.cloudMarketplacesSecret' "$DATA_FILE" | tee "$(results.cloudMarketplacesSecret.path)"
52132
jq -j '.mapping.cloudMarketplacesPrePush // false' "$DATA_FILE" | tee > "$(results.prePush.path)"
133+
- name: create-trusted-artifact
134+
ref:
135+
resolver: git
136+
params:
137+
- name: url
138+
value: $(params.taskGitUrl)
139+
- name: revision
140+
value: $(params.taskGitRevision)
141+
- name: pathInRepo
142+
value: stepactions/create-trusted-artifact/create-trusted-artifact.yaml
143+
params:
144+
- name: ociStorage
145+
value: $(params.ociStorage)
146+
- name: workDir
147+
value: $(params.dataDir)
148+
- name: sourceDataArtifact
149+
value: $(results.sourceDataArtifact.path)
150+
- name: patch-source-data-artifact-result
151+
ref:
152+
resolver: git
153+
params:
154+
- name: url
155+
value: $(params.taskGitUrl)
156+
- name: revision
157+
value: $(params.taskGitRevision)
158+
- name: pathInRepo
159+
value: stepactions/patch-source-data-artifact-result/patch-source-data-artifact-result.yaml
160+
params:
161+
- name: ociStorage
162+
value: $(params.ociStorage)
163+
- name: sourceDataArtifact
164+
value: $(results.sourceDataArtifact.path)

tasks/managed/collect-marketplacesvm-params/tests/test-collect-marketplacesvm-params-fail-no-data.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,108 @@ spec:
1010
Run the collect-marketplacesvm-params task with no data file and verify the taks fails as expected
1111
workspaces:
1212
- name: tests-workspace
13+
params:
14+
- name: ociStorage
15+
description: The OCI repository where the Trusted Artifacts are stored.
16+
type: string
17+
- name: ociArtifactExpiresAfter
18+
description: Expiration date for the trusted artifacts created in the
19+
OCI repository. An empty string means the artifacts do not expire.
20+
type: string
21+
default: "1d"
22+
- name: orasOptions
23+
description: oras options to pass to Trusted Artifacts calls
24+
type: string
25+
default: "--insecure"
26+
- name: trustedArtifactsDebug
27+
description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable.
28+
type: string
29+
default: ""
30+
- name: dataDir
31+
description: The location where data will be stored
32+
type: string
1333
tasks:
34+
- name: setup
35+
workspaces:
36+
- name: data
37+
workspace: tests-workspace
38+
taskSpec:
39+
results:
40+
- name: sourceDataArtifact
41+
type: string
42+
workspaces:
43+
- name: data
44+
volumes:
45+
- name: workdir
46+
emptyDir: {}
47+
stepTemplate:
48+
volumeMounts:
49+
- mountPath: /var/workdir
50+
name: workdir
51+
env:
52+
- name: IMAGE_EXPIRES_AFTER
53+
value: $(params.ociArtifactExpiresAfter)
54+
- name: "ORAS_OPTIONS"
55+
value: "$(params.orasOptions)"
56+
- name: "DEBUG"
57+
value: "$(params.trustedArtifactsDebug)"
58+
steps:
59+
- name: setup-values
60+
image: quay.io/konflux-ci/release-service-utils:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
61+
script: |
62+
#!/usr/bin/env sh
63+
set -eux
64+
65+
mkdir -p "$(params.dataDir)/results"
66+
# No data file created intentionally to test failure case
67+
- name: skip-trusted-artifact-operations
68+
ref:
69+
name: skip-trusted-artifact-operations
70+
params:
71+
- name: ociStorage
72+
value: $(params.ociStorage)
73+
- name: workDir
74+
value: $(params.dataDir)
75+
- name: create-trusted-artifact
76+
ref:
77+
name: create-trusted-artifact
78+
params:
79+
- name: ociStorage
80+
value: $(params.ociStorage)
81+
- name: workDir
82+
value: $(params.dataDir)
83+
- name: sourceDataArtifact
84+
value: $(results.sourceDataArtifact.path)
85+
- name: patch-source-data-artifact-result
86+
ref:
87+
name: patch-source-data-artifact-result
88+
params:
89+
- name: ociStorage
90+
value: $(params.ociStorage)
91+
- name: sourceDataArtifact
92+
value: $(results.sourceDataArtifact.path)
1493
- name: run-task
1594
taskRef:
1695
name: collect-marketplacesvm-params
1796
params:
1897
- name: dataPath
1998
value: data.json
99+
- name: ociStorage
100+
value: $(params.ociStorage)
101+
- name: orasOptions
102+
value: $(params.orasOptions)
103+
- name: sourceDataArtifact
104+
value: "$(tasks.setup.results.sourceDataArtifact)=$(params.dataDir)"
105+
- name: dataDir
106+
value: $(params.dataDir)
107+
- name: trustedArtifactsDebug
108+
value: $(params.trustedArtifactsDebug)
109+
- name: taskGitUrl
110+
value: "http://localhost"
111+
- name: taskGitRevision
112+
value: "main"
20113
workspaces:
21114
- name: data
22115
workspace: tests-workspace
116+
runAfter:
117+
- setup

tasks/managed/collect-marketplacesvm-params/tests/test-collect-marketplacesvm-params-fail-no-secret.yaml

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,60 @@ spec:
1111
verify the task fails as expected
1212
workspaces:
1313
- name: tests-workspace
14+
params:
15+
- name: ociStorage
16+
description: The OCI repository where the Trusted Artifacts are stored.
17+
type: string
18+
- name: ociArtifactExpiresAfter
19+
description: Expiration date for the trusted artifacts created in the
20+
OCI repository. An empty string means the artifacts do not expire.
21+
type: string
22+
default: "1d"
23+
- name: orasOptions
24+
description: oras options to pass to Trusted Artifacts calls
25+
type: string
26+
default: "--insecure"
27+
- name: trustedArtifactsDebug
28+
description: Flag to enable debug logging in trusted artifacts. Set to a non-empty string to enable.
29+
type: string
30+
default: ""
31+
- name: dataDir
32+
description: The location where data will be stored
33+
type: string
1434
tasks:
1535
- name: setup
1636
workspaces:
1737
- name: data
1838
workspace: tests-workspace
1939
taskSpec:
40+
results:
41+
- name: sourceDataArtifact
42+
type: string
2043
workspaces:
2144
- name: data
45+
volumes:
46+
- name: workdir
47+
emptyDir: {}
48+
stepTemplate:
49+
volumeMounts:
50+
- mountPath: /var/workdir
51+
name: workdir
52+
env:
53+
- name: IMAGE_EXPIRES_AFTER
54+
value: $(params.ociArtifactExpiresAfter)
55+
- name: "ORAS_OPTIONS"
56+
value: "$(params.orasOptions)"
57+
- name: "DEBUG"
58+
value: "$(params.trustedArtifactsDebug)"
2259
steps:
2360
- name: setup-values
2461
image: quay.io/konflux-ci/release-service-utils:6556e8a6b031c1aad4f0472703fd121a6e1cd45d
2562
script: |
2663
#!/usr/bin/env sh
2764
set -eux
2865
29-
cat > "$(workspaces.data.path)/data.json" << EOF
66+
mkdir -p "$(params.dataDir)/results"
67+
cat > "$(params.dataDir)/data.json" << EOF
3068
{
3169
"mapping": {
3270
"components": [
@@ -40,12 +78,52 @@ spec:
4078
}
4179
}
4280
EOF
81+
- name: skip-trusted-artifact-operations
82+
ref:
83+
name: skip-trusted-artifact-operations
84+
params:
85+
- name: ociStorage
86+
value: $(params.ociStorage)
87+
- name: workDir
88+
value: $(params.dataDir)
89+
- name: create-trusted-artifact
90+
ref:
91+
name: create-trusted-artifact
92+
params:
93+
- name: ociStorage
94+
value: $(params.ociStorage)
95+
- name: workDir
96+
value: $(params.dataDir)
97+
- name: sourceDataArtifact
98+
value: $(results.sourceDataArtifact.path)
99+
- name: patch-source-data-artifact-result
100+
ref:
101+
name: patch-source-data-artifact-result
102+
params:
103+
- name: ociStorage
104+
value: $(params.ociStorage)
105+
- name: sourceDataArtifact
106+
value: $(results.sourceDataArtifact.path)
43107
- name: run-task
44108
taskRef:
45109
name: collect-marketplacesvm-params
46110
params:
47111
- name: dataPath
48112
value: data.json
113+
- name: ociStorage
114+
value: $(params.ociStorage)
115+
- name: orasOptions
116+
value: $(params.orasOptions)
117+
- name: sourceDataArtifact
118+
value: "$(tasks.setup.results.sourceDataArtifact)=$(params.dataDir)"
119+
- name: dataDir
120+
value: $(params.dataDir)
121+
- name: trustedArtifactsDebug
122+
value: $(params.trustedArtifactsDebug)
123+
- name: taskGitUrl
124+
value: "http://localhost"
125+
- name: taskGitRevision
126+
value: "main"
49127
workspaces:
50128
- name: data
51129
workspace: tests-workspace

0 commit comments

Comments
 (0)