|
| 1 | +--- |
| 2 | +apiVersion: tekton.dev/v1 |
| 3 | +kind: Pipeline |
| 4 | +metadata: |
| 5 | + name: test-update-cr-status-advisory-from-filter |
| 6 | +spec: |
| 7 | + description: | |
| 8 | + Run the update-cr-status task with a single resultArtifact that contains only |
| 9 | + the filter-already-released-advisory-images results file — the same setup used |
| 10 | + by the update-cr-status-skipped pipeline task on the idempotent re-release path |
| 11 | + (skip_release=true). The task should patch the Release CR status with |
| 12 | + advisory.url and advisory.internal_url. |
| 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 |
| 33 | + tasks: |
| 34 | + - name: setup |
| 35 | + taskSpec: |
| 36 | + results: |
| 37 | + - name: sourceDataArtifact |
| 38 | + type: string |
| 39 | + volumes: |
| 40 | + - name: workdir |
| 41 | + emptyDir: {} |
| 42 | + stepTemplate: |
| 43 | + volumeMounts: |
| 44 | + - mountPath: /var/workdir |
| 45 | + name: workdir |
| 46 | + env: |
| 47 | + - name: IMAGE_EXPIRES_AFTER |
| 48 | + value: $(params.ociArtifactExpiresAfter) |
| 49 | + - name: "ORAS_OPTIONS" |
| 50 | + value: "$(params.orasOptions)" |
| 51 | + - name: "DEBUG" |
| 52 | + value: "$(params.trustedArtifactsDebug)" |
| 53 | + steps: |
| 54 | + - name: setup |
| 55 | + image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 |
| 56 | + script: | |
| 57 | + #!/usr/bin/env bash |
| 58 | + set -eux |
| 59 | +
|
| 60 | + RESULTS_DIR="$(params.dataDir)/$(context.pipelineRun.uid)/results" |
| 61 | + mkdir -p "$RESULTS_DIR" |
| 62 | +
|
| 63 | + # Simulate the results file written by filter-already-released-advisory-images |
| 64 | + # when all snapshot images are already published in an existing advisory |
| 65 | + FILTER_RESULTS="$RESULTS_DIR/filter-already-released-advisory-images-results.json" |
| 66 | + cat > "$FILTER_RESULTS" << EOF |
| 67 | + { |
| 68 | + "advisory": { |
| 69 | + "url": "https://access.redhat.com/errata/RHSA-2024:12345", |
| 70 | + "internal_url": "https://errata.devel.redhat.com/advisory/12345" |
| 71 | + } |
| 72 | + } |
| 73 | + EOF |
| 74 | +
|
| 75 | + cat > "$(params.dataDir)/$(context.pipelineRun.uid)/release" << EOF |
| 76 | + apiVersion: appstudio.redhat.com/v1alpha1 |
| 77 | + kind: Release |
| 78 | + metadata: |
| 79 | + name: release-cr-status-advisory |
| 80 | + namespace: default |
| 81 | + spec: |
| 82 | + snapshot: foo |
| 83 | + releasePlan: foo |
| 84 | + EOF |
| 85 | + kubectl apply -f "$(params.dataDir)/$(context.pipelineRun.uid)/release" |
| 86 | + - name: create-trusted-artifact |
| 87 | + ref: |
| 88 | + name: create-trusted-artifact |
| 89 | + params: |
| 90 | + - name: ociStorage |
| 91 | + value: $(params.ociStorage) |
| 92 | + - name: workDir |
| 93 | + value: $(params.dataDir) |
| 94 | + - name: sourceDataArtifact |
| 95 | + value: $(results.sourceDataArtifact.path) |
| 96 | + - name: run-task |
| 97 | + taskRef: |
| 98 | + name: update-cr-status |
| 99 | + params: |
| 100 | + - name: resource |
| 101 | + value: default/release-cr-status-advisory |
| 102 | + - name: resultsDirPath |
| 103 | + value: $(context.pipelineRun.uid)/results |
| 104 | + - name: dataDir |
| 105 | + value: $(params.dataDir) |
| 106 | + - name: ociStorage |
| 107 | + value: $(params.ociStorage) |
| 108 | + - name: orasOptions |
| 109 | + value: $(params.orasOptions) |
| 110 | + - name: trustedArtifactsDebug |
| 111 | + value: $(params.trustedArtifactsDebug) |
| 112 | + - name: resultArtifacts |
| 113 | + value: |
| 114 | + - "$(tasks.setup.results.sourceDataArtifact)=$(params.dataDir)" |
| 115 | + - name: taskGitUrl |
| 116 | + value: "http://localhost" |
| 117 | + - name: taskGitRevision |
| 118 | + value: "main" |
| 119 | + runAfter: |
| 120 | + - setup |
| 121 | + - name: check-result |
| 122 | + taskSpec: |
| 123 | + steps: |
| 124 | + - name: check-result |
| 125 | + image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 |
| 126 | + script: | |
| 127 | + #!/usr/bin/env bash |
| 128 | + set -eux |
| 129 | +
|
| 130 | + echo Test that Release.Status contains advisory.url from the filter task results |
| 131 | + test "$(kubectl get release release-cr-status-advisory -n default \ |
| 132 | + -o jsonpath='{.status.artifacts.advisory.url}')" \ |
| 133 | + == "https://access.redhat.com/errata/RHSA-2024:12345" |
| 134 | +
|
| 135 | + echo Test that Release.Status contains advisory.internal_url from the filter task results |
| 136 | + test "$(kubectl get release release-cr-status-advisory -n default \ |
| 137 | + -o jsonpath='{.status.artifacts.advisory.internal_url}')" \ |
| 138 | + == "https://errata.devel.redhat.com/advisory/12345" |
| 139 | + runAfter: |
| 140 | + - run-task |
| 141 | + finally: |
| 142 | + - name: cleanup |
| 143 | + taskSpec: |
| 144 | + steps: |
| 145 | + - name: delete-crs |
| 146 | + image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 |
| 147 | + script: | |
| 148 | + #!/usr/bin/env sh |
| 149 | + set -eux |
| 150 | +
|
| 151 | + kubectl delete release release-cr-status-advisory |
0 commit comments