-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-ocp-release-configmap
executable file
·36 lines (35 loc) · 1.16 KB
/
generate-ocp-release-configmap
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
#!/bin/bash
TARGET_VERSION=$1
IMAGE_URL=$2
ARCH=$3
if test -z "$TARGET_VERSION" -o -z "$IMAGE_URL"
then
echo "Usage: $0 <ocp version> <image url> [<architecture>]" >&2
exit 1
fi
if test -z "$ARCH"
then
ARCH=x86_64
echo "using $ARCH for architecture"
fi
# Based on: https://dev.to/baptistemm/openshift-z-patch-upgrade-in-restricted-environment-without-mirroring-quay-io-5em3
export OCP_RELEASE_NUMBER=${TARGET_VERSION}
export DIGEST=${IMAGE_URL##*/}
export SIGNATURE_BASE64=$(curl -s "https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/$(echo $DIGEST | cut -d: -f1)=$(echo $DIGEST | cut -d: -f2)/signature-1" | base64 -w0 && echo)
export DIGEST_ALGO=$(echo $DIGEST | cut -d: -f1)
export DIGEST_SIGNATURE=$(echo $DIGEST | cut -d: -f2)
OUTPUT_FILE=release-image-${OCP_RELEASE_NUMBER}-${ARCH}-configmap.yaml
cat <<EOF > $OUTPUT_FILE
apiVersion: v1
kind: ConfigMap
metadata:
name: release-image-${OCP_RELEASE_NUMBER}
namespace: openshift-config-managed
annotations:
image.url: $IMAGE_URL
labels:
release.openshift.io/verification-signatures: ""
binaryData:
${DIGEST_ALGO}-${DIGEST_SIGNATURE}: ${SIGNATURE_BASE64}
EOF
echo "wrote $OUTPUT_FILE"