audit fixes: error handling, docs consistency, bucket idempotency
Provision server / provision (push) Successful in 12s

This commit is contained in:
2026-03-20 11:28:36 -04:00
parent 6b1e78350f
commit be1ad6b456
8 changed files with 61 additions and 13 deletions
+20 -3
View File
@@ -204,6 +204,15 @@ done
# --- Create Gitea repo from template ---
REPO_CHECK=$(curl -s -o /dev/null -w "%{http_code}" \
"$GITEA_URL/api/v1/repos/$GITEA_ORG/$APP" \
-H "Authorization: token $GITEA_TOKEN")
if [ "$REPO_CHECK" = "200" ]; then
echo "Error: Gitea repo $GITEA_ORG/$APP already exists."
echo " $GITEA_URL/$GITEA_ORG/$APP"
exit 1
fi
echo "Creating Gitea repo $GITEA_ORG/$APP from template $TEMPLATE_REPO..."
HTTP_CODE=$(curl -s -o /tmp/new-app-response.json -w "%{http_code}" \
-X POST "$GITEA_URL/api/v1/repos/$GITEA_ORG/$TEMPLATE_REPO/generate" \
@@ -343,9 +352,17 @@ BUCKET_RESP=$(curl -s -X POST "$GARAGE_API/v2/CreateBucket" \
BUCKET_ID=$(echo "$BUCKET_RESP" | jq -r '.id')
if [ -z "$BUCKET_ID" ] || [ "$BUCKET_ID" = "null" ]; then
echo "Error: Failed to create bucket"
echo "$BUCKET_RESP"
exit 1
# Bucket may already exist — try to look it up
BUCKET_ID=$(curl -s -X POST "$GARAGE_API/v2/GetBucketInfo" \
-H "$GARAGE_AUTH" \
-H "Content-Type: application/json" \
-d "{\"globalAlias\": \"$APP\"}" | jq -r '.id')
if [ -z "$BUCKET_ID" ] || [ "$BUCKET_ID" = "null" ]; then
echo "Error: Failed to create or find bucket for $APP"
echo "$BUCKET_RESP"
exit 1
fi
echo " Bucket already exists, continuing..."
fi
echo " Allowing media-key access..."