From 7072d37541690a3b7bf66f2efd7ee7207f5d4150 Mon Sep 17 00:00:00 2001 From: Tudor Date: Tue, 24 Mar 2026 20:03:07 +0000 Subject: [PATCH] fix(kestra-init): add basic auth support via KESTRA_USER/KESTRA_PASSWORD Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 2 ++ integrator/docker/kestra-init.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7002001..cc6b4e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -116,6 +116,8 @@ services: container_name: schoolcompare_kestra_init environment: KESTRA_URL: http://kestra:8080 + KESTRA_USER: ${KESTRA_USER:-} + KESTRA_PASSWORD: ${KESTRA_PASSWORD:-} depends_on: kestra: condition: service_healthy diff --git a/integrator/docker/kestra-init.sh b/integrator/docker/kestra-init.sh index 96998d0..91885c8 100644 --- a/integrator/docker/kestra-init.sh +++ b/integrator/docker/kestra-init.sh @@ -4,9 +4,15 @@ set -e KESTRA_URL="${KESTRA_URL:-http://kestra:8080}" MAX_WAIT=120 +# Basic auth — set KESTRA_USER / KESTRA_PASSWORD if authentication is enabled +AUTH="" +if [ -n "$KESTRA_USER" ] && [ -n "$KESTRA_PASSWORD" ]; then + AUTH="-u ${KESTRA_USER}:${KESTRA_PASSWORD}" +fi + echo "Waiting for Kestra API at ${KESTRA_URL}..." elapsed=0 -until curl -sf "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do +until curl -sf $AUTH "${KESTRA_URL}/api/v1/flows/search" > /dev/null 2>&1; do if [ "$elapsed" -ge "$MAX_WAIT" ]; then echo "ERROR: Kestra API not reachable after ${MAX_WAIT}s" exit 1 @@ -22,7 +28,7 @@ for f in /flows/*.yml; do name="$(basename "$f")" echo " -> $name" - http_code=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \ + http_code=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \ -X POST "${KESTRA_URL}/api/v1/flows" \ -H "Content-Type: application/x-yaml" \ --data-binary "@${f}") @@ -32,7 +38,7 @@ for f in /flows/*.yml; do elif [ "$http_code" = "409" ]; then ns=$(grep '^namespace:' "$f" | awk '{print $2}') id=$(grep '^id:' "$f" | awk '{print $2}') - http_code2=$(curl -s -o /tmp/kestra_resp -w "%{http_code}" \ + http_code2=$(curl -s $AUTH -o /tmp/kestra_resp -w "%{http_code}" \ -X PUT "${KESTRA_URL}/api/v1/flows/${ns}/${id}" \ -H "Content-Type: application/x-yaml" \ --data-binary "@${f}")