Skip to content

Commit

Permalink
Upgrade bonfire and handle errors in deploy.sh (#63)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lpichler authored May 9, 2024
1 parent 580ef91 commit 5748a03
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ docker run --rm -p 8000:8000 -p 9000:9000 -v </path/to/your/configs>:/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
Expand Down
20 changes: 19 additions & 1 deletion deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5748a03

Please sign in to comment.