Skip to content

Commit 0ce265b

Browse files
committed
feat(RELEASE-2092): get snapshot from kubearchive if deleted
The catalog tasks mostly use the get-resource script in release-utils-repo to get Kubernetes resources. For snapshots, this script has been modified to fallback to kubearchive if the resource had been deleted [1]. This approach doesn't work if the get-resource script isn't used to get the snapshot. This commit modifies the one instance where this happens to use the get-resource script, ensuring that the kubearchive fallback is used. [1] konflux-ci/release-service-utils#657 Assisted-by: Cursor Signed-off-by: Lubomir Gallovic <lgallovi@redhat.com>
1 parent 9199240 commit 0ce265b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tasks/managed/reduce-snapshot/reduce-snapshot.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ spec:
148148
exit 0
149149
fi
150150
151-
CR_NAMESPACE_ARG=
152-
if [ "${CUSTOM_RESOURCE_NAMESPACE}" != "" ]; then
153-
CR_NAMESPACE_ARG="-n ${CUSTOM_RESOURCE_NAMESPACE}"
151+
CR_TYPE="${CUSTOM_RESOURCE%%/*}"
152+
CR_NAME="${CUSTOM_RESOURCE#*/}"
153+
154+
CR_NS="${CUSTOM_RESOURCE_NAMESPACE}"
155+
if [ -z "${CR_NS}" ]; then
156+
CR_NS=$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)
157+
CR_NS="${CR_NS:-default}"
154158
fi
155159
156-
LABELS=$(kubectl get "$CUSTOM_RESOURCE" ${CR_NAMESPACE_ARG:+$CR_NAMESPACE_ARG} -ojson \
157-
| jq -r '.metadata.labels')
160+
LABELS=$(get-resource "${CR_TYPE}" "${CR_NS}/${CR_NAME}" "{.metadata.labels}")
158161
SNAPSHOT_CREATION_TYPE=$(jq -r '."test.appstudio.openshift.io/type" // ""' <<< "${LABELS}")
159162
SNAPSHOT_CREATION_COMPONENT=$(jq -r '."appstudio.openshift.io/component" // ""' <<< "${LABELS}")
160163

0 commit comments

Comments
 (0)