From 5748a03961c35a8f13143d1ff448adfd14cd58cb Mon Sep 17 00:00:00 2001 From: Libor Pichler Date: Thu, 9 May 2024 11:13:54 +0200 Subject: [PATCH] Upgrade bonfire and handle errors in deploy.sh (#63) * Upgrade bonfire in deploy script * Ensure deploy.sh exits on command failure in deploy.sh * Add pre-creation check for spicedb-schema configmap in deploy.sh * Move bonfire upgrade into readme and check minimal versions in deploy.sh * use pip upgrade command for bonfire in deploy.sh and readme --- README.md | 10 ++++++++++ deploy/deploy.sh | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b23b695..50a6c43 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,16 @@ docker run --rm -p 8000:8000 -p 9000:9000 -v :/data/conf ### Prerequisite [bonfire](https://github.com/RedHatInsights/bonfire) + +NOTE: The minimum required version of [bonfire](https://github.com/RedHatInsights/bonfire) +is specified in the MIN_BONFIRE_VERSION variable in the deploy.sh script +Bonfire could be upgraded by command: +```asciidoc +pip install --upgrade crc-bonfire +``` +Latest version of [bonfire](https://github.com/RedHatInsights/bonfire) could be found [here](https://github.com/RedHatInsights/bonfire/releases). + + [oc](https://docs.openshift.com/container-platform/4.8/cli_reference/openshift_cli/getting-started-cli.html) You should have logged into a valid openshift cluster using the oc login command diff --git a/deploy/deploy.sh b/deploy/deploy.sh index f1d9899..393be7c 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -1,4 +1,8 @@ #!/bin/bash +set -e + +# Define the minimum required version +MIN_BONFIRE_VERSION="5.7.2" RBAC_ARGUMENT="$1" RBAC_DIR="$2" @@ -29,6 +33,15 @@ else exit 1 fi +CURRENT_BONFIRE_VERSION=$(bonfire version | cut -d' ' -f3) + +if [[ $(printf '%s\n' "$MIN_BONFIRE_VERSION" "$CURRENT_BONFIRE_VERSION" | sort -V | head -n1) != "$MIN_BONFIRE_VERSION" ]]; then + echo "Current bonfire version ($CURRENT_BONFIRE_VERSION) is less than required version ($MIN_BONFIRE_VERSION)." + echo "Please upgrade bonfire with command:" + echo "pip install --upgrade crc-bonfire" + exit 1 +fi + # Check if there is an existing NS RESERVATIONS=$(bonfire namespace list -m) @@ -86,7 +99,12 @@ done echo "postgress is ready" # Create spiceDB bootstrap schema configmap -oc create configmap spicedb-schema --from-file=schema.yaml -n $NAMESPACE + +if ! oc get configmap spicedb-schema >/dev/null 2>&1; then + oc create configmap spicedb-schema --from-file=schema.yaml -n $NAMESPACE +else + echo "Configmap 'spicedb-schema' already exists." +fi #Deploy Relations service, spiceDB service and rbac service when $RBAC_ARGUMENT is not empty bonfire deploy $RBAC_ARGUMENT relationships -n $NAMESPACE --local-config-method merge --local-config-path $config_file_location