From 80d55e4db14897e96959b35f27e73c82f53f5435 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 16 Jan 2024 18:04:39 -0500 Subject: [PATCH] feat(buckets): add CRYOSTAT_BUCKETS for pre-created buckets --- cryostat-entrypoint.bash | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cryostat-entrypoint.bash b/cryostat-entrypoint.bash index 68ef82c..18b01f7 100755 --- a/cryostat-entrypoint.bash +++ b/cryostat-entrypoint.bash @@ -15,6 +15,26 @@ set -xe cfg="$(mktemp)" envsubst '$CRYOSTAT_ACCESS_KEY $CRYOSTAT_SECRET_KEY' < /etc/seaweed_conf.template.json > "${cfg}" +function createBuckets() { + for i in $(echo "$CRYOSTAT_BUCKETS" | tr ',' '\n'); do + local len + len="${#i}" + if [ "${len}" -lt 3 ]; then + echo "Bucket names must be at least 3 characters" + exit 1 + fi + if [ "${len}" -gt 63 ]; then + echo "Bucket names must be at most 63 characters" + exit 1 + fi + local cmd + # FIXME do something better than sleeping here + cmd="sleep ${BUCKET_CREATION_STARTUP_SECONDS:-30} ; echo \"s3.bucket.create -name ${i}\" | weed shell" + bash -c "${cmd}" & + done +} +createBuckets + exec /usr/bin/entrypoint.sh \ server -dir="${DATA_DIR:-/tmp}" \ -s3 -s3.config="${cfg}" \