Files
JC Beasley d8989f9371 Migrate all scripts to use vault cache
All NocoDB/Grist API scripts now use vault-env.sh instead of direct Vault queries:

Updated scripts:
- checks/check-agent.sh
- checks/check-memory-table.sh (already done)
- fixes/fix-columns.sh
- fixes/fix-severity-status.sh
- fixes/fix-status-col.sh
- fixes/fix-status-only.sh
- fixes/fix-type-col.sh
- fixes/fix-type-options.sh
- fixes/fix-type-v2.sh
- utils/debug-coloptions.sh
- utils/get-col-id.sh
- utils/get-columns.sh (already done)
- utils/recreate-type-column.sh
- utils/update-column-options.sh
- utils/update-type-col.sh (already done)
- get_grist_token.sh
- grist_api.sh
- refresh_tokens.sh
- store_grist_token.sh
- update_survey_dates.sh
- vault_api.sh (tries cache first, falls back to direct)
- vault_auth.sh (tries cache first, falls back to direct)

Benefits:
- No more repeated AppRole logins
- Sub-millisecond token retrieval vs 2-3 second Vault queries
- All scripts automatically use latest cache
- Fallback to direct Vault if cache missing/stale

Pattern:
  source vault-env.sh
  TOKEN=***  # instant from cache

Closes: vault cache migration
2026-07-19 09:00:01 -07:00

48 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Uses vault cache for fast token retrieval
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../vault-env.sh"
NOCODB_TOKEN=$(vaul…ken)
if [ -z "$NOCODB_TOKEN" ]; then
echo "Error: Could not retrieve NocoDB token"
exit 1
fi
# Get tokens
echo "Updating severity column..."
# Update severity column (ID: cv1al80v3ejvij0)
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cv1al80v3ejvij0" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "error,warning,auto-correct",
"meta": {
"options": [
{"title": "error", "color": "#FF0000"},
{"title": "warning", "color": "#FFA500"},
{"title": "auto-correct", "color": "#FFFF00"}
]
}
}'
echo ""
echo "Updating status column..."
# Update status column (ID: cxbxnyh03nkvd0a)
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/cxbxnyh03nkvd0a" \
-H "xc-token: $NOCODB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dtxp": "active,reversed,deprecated",
"meta": {
"options": [
{"title": "active", "color": "#00FF00"},
{"title": "reversed", "color": "#FFA500"},
{"title": "deprecated", "color": "#808080"}
]
}
}'
echo ""
echo "Done!"