Refactor json schema on status api
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/cron/woodpecker Pipeline failed

This commit is contained in:
dvirlabs 2026-04-26 02:54:02 +03:00
parent 7a83b68feb
commit a42c3f5e95
2 changed files with 9 additions and 5 deletions

View File

@ -86,6 +86,8 @@ steps:
# Runs on push to master only, after deploy succeeds.
# Generates structured JSON with sync status, drift count, and changed files.
# Sends JSON to gitops-status-server for Grafana visualization.
# Endpoint: POST /api/rsyslog/status
# Note: Each server type has its own endpoint: /api/{server_type}/status
# ---------------------------------------------------------------------------
update-gitops-status:
image: alpine/ansible:latest
@ -133,6 +135,8 @@ steps:
# Detects manual changes made directly on the server between pushes.
# Generates structured JSON with sync status, drift count, and changed files.
# Sends JSON to gitops-status-server for continuous GitOps monitoring.
# Endpoint: GET/POST /api/rsyslog/status
# Note: Each server type has its own endpoint: /api/{server_type}/status
# Pipeline always succeeds - check Grafana dashboard for drift status.
#
# ─── Woodpecker Cron UI settings ──────────────────────────────────────────

View File

@ -251,7 +251,7 @@ else
# Drift-check mode: Keep existing deployed_files, only update drifted_files
# First fetch current status to preserve deployed_files
echo " Fetching current deployed_files from API..."
CURRENT_JSON=$(curl -s "$GITOPS_STATUS_SERVER_URL/api/status" 2>/dev/null || echo "{}")
CURRENT_JSON=$(curl -s "$GITOPS_STATUS_SERVER_URL/api/rsyslog/status" 2>/dev/null || echo "{}")
# Extract deployed_files from current JSON (use jq if available)
if command -v jq >/dev/null 2>&1; then
@ -302,13 +302,13 @@ echo ""
# Step 4: Send JSON to gitops-status-server
# ─────────────────────────────────────────────────────────────────────────────────
echo "Step 4/4: Sending status to gitops-status-server..."
echo " URL: $GITOPS_STATUS_SERVER_URL/api/status"
echo " URL: $GITOPS_STATUS_SERVER_URL/api/rsyslog/status"
echo " Method: POST"
echo " Request Payload:"
echo "$STATUS_JSON" | jq '.' 2>/dev/null | sed 's/^/ /' || echo "$STATUS_JSON" | sed 's/^/ /'
echo ""
echo "Step 4/4: Sending status to gitops-status-server..."
echo " URL: $GITOPS_STATUS_SERVER_URL/api/status"
echo " URL: $GITOPS_STATUS_SERVER_URL/api/rsyslog/status"
echo " Method: POST"
echo " Payload size: $(echo "$STATUS_JSON" | wc -c) bytes"
echo ""
@ -334,7 +334,7 @@ RESPONSE_BODY=$(mktemp)
trap "rm -f $RESPONSE_BODY $PLAYBOOK_LOG" EXIT
echo " Sending POST request with curl..."
echo " Command: curl -X POST -H 'Content-Type: application/json' -d '<JSON>' $GITOPS_STATUS_SERVER_URL/api/status"
echo " Command: curl -X POST -H 'Content-Type: application/json' -d '<JSON>' $GITOPS_STATUS_SERVER_URL/api/rsyslog/status"
echo ""
# POST the JSON to the gitops-status-server API with full error reporting
@ -344,7 +344,7 @@ HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Content-Type: application/json" \
-d "$STATUS_JSON" \
"$GITOPS_STATUS_SERVER_URL/api/status" \
"$GITOPS_STATUS_SERVER_URL/api/rsyslog/status" \
2>&1)
CURL_EXIT=$?
set -e