Files
backend/bin/config-push
2024-07-26 23:34:09 -04:00

52 lines
991 B
Bash
Executable File

#!/bin/bash
SCRIPT_DIR="$(dirname -- "$( readlink -f -- "$0"; )";)"
CONF_DIR="$SCRIPT_DIR/../conf"
if [ "$1" == "" ]; then
echo 'usage: config-push {config_name} [secret_name]'
exit 1
fi
CONFIG=$1
shift
if [ "$1" != "" ]; then
KEY=backend-$1
else
KEY=backend
fi
DEXO="$CONF_DIR/dexorder-$CONFIG.toml"
if [ ! -f "$DEXO" ]; then
DEXO="$CONF_DIR/$CONFIG/dexorder-$CONFIG.toml"
fi
if [ ! -f "$DEXO" ]; then
DEXO=
else
DEXO="--from-file dexorder.toml=$DEXO"
fi
LOG="$CONF_DIR/logging-$CONFIG.toml"
if [ ! -f "$LOG" ]; then
LOG="$CONF_DIR/$CONFIG/logging-$CONFIG.toml"
fi
if [ ! -f "$LOG" ]; then
LOG=
else
LOG="--from-file logging.toml=$LOG"
fi
META="$CONF_DIR/metadata-$CONFIG.json"
if [ ! -f "$META" ]; then
META="$CONF_DIR/$CONFIG/metadata-$CONFIG.json"
fi
if [ ! -f "$META" ]; then
META=
else
META="--from-file metadata.json=$META"
fi
# shellcheck disable=SC2086
kubectl create configmap "$KEY" $DEXO $LOG $META --dry-run=client -o yaml | kubectl apply -f -