From a42c3f5e95ce1a08ae40a1f88904c01a9156c54e Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Sun, 26 Apr 2026 02:54:02 +0300 Subject: [PATCH] Refactor json schema on status api --- .woodpecker.yml | 4 ++++ update-gitops-status.sh | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 1fc6d9f..ffa1468 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -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 ────────────────────────────────────────── diff --git a/update-gitops-status.sh b/update-gitops-status.sh index 65bbbb1..a9c5f77 100644 --- a/update-gitops-status.sh +++ b/update-gitops-status.sh @@ -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 '' $GITOPS_STATUS_SERVER_URL/api/status" +echo " Command: curl -X POST -H 'Content-Type: application/json' -d '' $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