From 138e2da8b371d7c54efbbb42fcf4da7935f079a9 Mon Sep 17 00:00:00 2001 From: Tessa Walsh Date: Wed, 10 Jan 2024 22:32:39 -0500 Subject: [PATCH] Add setup command to btrix helper to copy local config (#1462) Fixes #1157 Adds `./btrix setup` command to `btrix` helper which copies the example local config to `./chart/local.yaml` where `btrix` expects it. If another command is run when the local config file doesn't yet exist, the helper will stop and suggest to the user to run `./btrix setup` and edit the resulting file. --- btrix | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/btrix b/btrix index 6c02355f..b424e292 100755 --- a/btrix +++ b/btrix @@ -2,14 +2,15 @@ # ./btrix: Browsertrix Cloud dev environment utility # -# Note: btrix helper expects a local.yaml file to exist in -# the chart directory alongside values.yaml. -# # Test commands require installing pytest first, e.g.: # python3 -m pip install pytest # # Usage: # +# $ ./btrix setup +# Copy local config to expected location +# Local config must exist for other commands to work +# # $ ./btrix bootstrap # Build frontend and backend and upgrade # Optional args: @@ -104,10 +105,30 @@ runNightlyTests() { python3 -m pytest backend/test_nightly/test_*.py } +setupLocalConfig() { + if [ -f ./chart/local.yaml ]; then + echo "Local config file already exists at ./chart/local.yaml" + exit 1 + fi + echo "Copying local example config to ./chart/local.yaml" + cp ./chart/examples/local-config.yaml ./chart/local.yaml + echo "Local config file created. Edit ./chart/local.yaml to set local overrides" + exit 0 +} + CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //") MICROK8S="-microk8s" WAIT="-wait" +if [[ $1 = "setup" ]]; then + setupLocalConfig +fi + +if [ ! -f ./chart/local.yaml ]; then + echo "Local config file not found. Run './btrix setup' to configure" + exit 1 +fi + # bootstrap: build frontend and backend, upgrade and wait until ready if [[ $1 = "bootstrap" ]]; then