# Shared pod-status helpers for the operations scripts (sourced, not executed). # # POD_STATUS_JSONPATH renders one line per pod, "||", # with plain kubectl jsonpath (no template variables): the Ready status is "True", # "False" or empty when the pod has no Ready condition yet, and the deletion field is # empty unless the pod is being deleted. single_ready_pod reads such lines on stdin # and prints the one Ready pod not being deleted; zero or several candidates fail # (review M8 P2: never concatenate names or guess). tools/ci/ops-lib-check.sh tests it # offline with fixtures. # shellcheck disable=SC2034 # Used by the scripts that source this file. POD_STATUS_JSONPATH='{range .items[*]}{.metadata.name}{"|"}{.status.conditions[?(@.type=="Ready")].status}{"|"}{.metadata.deletionTimestamp}{"\n"}{end}' single_ready_pod() { local ready count ready="$(awk -F'|' 'NF >= 2 && $1 != "" && $2 == "True" && $3 == "" {print $1}')" count="$(grep -c . <<< "$ready" || true)" if [ "$count" != 1 ]; then echo "expected exactly one Ready pod, found $count${ready:+: ${ready//$'\n'/ }}" >&2 return 1 fi printf '%s\n' "$ready" }