#!/usr/bin/env python3 """Extract non-secret Argo CD application health evidence.""" import json import sys try: app = json.load(sys.stdin) status = app.get("status") or {} health = status.get("health") or {} operation = status.get("operationState") or {} print("health:", health.get("status", "Unknown")) if health.get("message"): print("health message:", health["message"]) if operation.get("phase"): print("last operation:", operation["phase"]) if operation.get("message"): print("operation message:", operation["message"]) for resource in status.get("resources") or []: resource_health = (resource.get("health") or {}).get("status", "") if resource_health and resource_health != "Healthy": print("resource:", resource.get("kind", "?"), resource.get("namespace", ""), resource.get("name", "?"), resource_health) except (ValueError, TypeError, AttributeError) as exc: print("Cannot parse application evidence:", exc, file=sys.stderr) sys.exit(1)