-
Notifications
You must be signed in to change notification settings - Fork 134
/
olm-operator-upgrade.sh
executable file
·38 lines (30 loc) · 1.31 KB
/
olm-operator-upgrade.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
#!/bin/bash
# Upgrades the operator to the most recent version.
# Assumes a previous version is already installed via OLM using olm-operator-install.sh.
set -eu -o pipefail
# shellcheck source=./common.sh
source "$(dirname "$0")/common.sh"
declare allow_dirty_tag=false
function main() {
case "$1" in
-d | --allow-dirty-tag)
allow_dirty_tag=true
shift
;;
esac
if [[ $# -ne 2 ]]; then
echo "Usage: $0 [-d | --allow-dirty-tag] <operator_ns> <operator-version>" >&2
exit 1
fi
local -r operator_ns="${1:-}"
local -r operator_version="${2:-}"
# Unfortunately simply changing to automatic approval does not work:
# https://github.com/operator-framework/operator-lifecycle-manager/issues/2341
# kubectl -n "${operator_ns}" patch subscription.operators.coreos.com stackrox-operator-test-subscription \
# --type=json -p '[{"op": "remove", "path": "/spec/startingCSV"}, {"op": "replace", "path": "/spec/installPlanApproval", "value": "Automatic"}]'
# However OLM happens to create an install plan for the latest version anyway, as soon as the old one is done, so we just have to approve it:
check_version_tag "${operator_version}" "${allow_dirty_tag}"
approve_install_plan "${operator_ns}" "${operator_version}"
nurse_deployment_until_available "${operator_ns}" "${operator_version}"
}
main "$@"