-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathhf.cluster.adapter.post.status.sh
More file actions
executable file
·70 lines (62 loc) · 1.99 KB
/
Copy pathhf.cluster.adapter.post.status.sh
File metadata and controls
executable file
·70 lines (62 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Post adapter status for current cluster
# Usage: hf.adapter.status.sh <adapter_name> <available> [generation]
source "$(dirname "$(realpath "$0")")/hf.lib.sh"
hf_require_config api-url api-version cluster-id
ADAPTER_NAME="${1:-}"
AVAILABLE="${2:-}"
GENERATION="${3:-1}"
if [[ -z "$ADAPTER_NAME" ]] || [[ -z "$AVAILABLE" ]]; then
hf_usage "<adapter_name> <available> [generation]"
echo "Arguments:"
echo " adapter_name Name of the adapter (e.g., validator, dns, provisioner)"
echo " available Status: True, False, or Unknown"
echo " generation Observed generation (default: 1)"
echo ""
echo "Example: hf.adapter.status.sh validator True 1"
exit 1
fi
# Validate available status
if [[ ! "$AVAILABLE" =~ ^(True|False|Unknown)$ ]]; then
hf_die "available must be 'True', 'False', or 'Unknown'"
fi
hf_require_jq
CLUSTER_ID=$(hf_cluster_id)
OBSERVED_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
hf_info "Posting adapter status: $ADAPTER_NAME = $AVAILABLE (gen: $GENERATION)"
PAYLOAD=$(
cat <<EOF
{
"adapter": "${ADAPTER_NAME}",
"observed_generation": ${GENERATION},
"observed_time": "${OBSERVED_TIME}",
"conditions": [
{
"type": "Available",
"status": "${AVAILABLE}",
"reason": "ManualStatusPost",
"message": "Status posted via hf.adapter.status.sh"
},
{
"type": "Applied",
"status": "${AVAILABLE}",
"reason": "ManualStatusPost",
"message": "Status posted via hf.adapter.status.sh"
},
{
"type": "Health",
"status": "${AVAILABLE}",
"reason": "ManualStatusPost",
"message": "Status posted via hf.adapter.status.sh"
},
{
"type": "Finalized",
"status": "${AVAILABLE}",
"reason": "ManualStatusPost",
"message": "Status posted via hf.adapter.status.sh"
}
]
}
EOF
)
hf_post "/clusters/${CLUSTER_ID}/statuses" "$PAYLOAD" | jq