-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.sh
executable file
·47 lines (37 loc) · 1.35 KB
/
update.sh
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
#!/usr/bin/env sh
# Print what you're doing, exit on error.
set -xe
# Which OCP version are we running this for.
VERSION="$1"
# Check that a folder exists for the version you set.
ls "$VERSION" > /dev/null
# Make script fail when API requests fail.
alias curl="curl --fail"
# Get the latest merge commit for the bundle. This is the string the bundle image is tagged with.
get_tag () {
URL="https://api.github.com/repos/openshift/trustee-operator/commits?per_page=1&path=bundle"
COMMIT=$(curl "$URL" | jq -r '.[0].sha')
URL="https://api.github.com/repos/openshift/trustee-operator/commits/$COMMIT/pulls"
curl "$URL" | jq -r '.[0].merge_commit_sha'
}
# Get the digest for a tagged image. Pass the <TAG> as the first argument.
# Quay API docs are at https://docs.quay.io/api/swagger/#!/tag/listRepoTags.
get_digest () {
TAG="$1"
URL="https://quay.io/api/v1/repository/redhat-user-workloads/ose-osc-tenant/trustee/trustee-operator-bundle/tag?specificTag=$TAG"
curl -L "$URL" | jq -r '.tags[0].manifest_digest'
}
# Replace any digest in the <FILE> with the new <DIGEST>.
replace_digest () {
DIGEST="$1"
FILE="$2"
sed -E -i "s/sha256:[0-9a-f]{64}/$DIGEST/" "$FILE"
}
TAG="$(get_tag)"
DIGEST="$(get_digest $TAG)"
FILE="$VERSION/catalog-template.json"
replace_digest "$DIGEST" "$FILE"
# No more debug. All went good.
set +x
echo "
Done."