pub fn find_by_kind<'a>(docs: &'a [Value], kind: &str) -> Option<&'a Value>Expand description
Locate the first K8s CR YAML document in docs whose top-level
kind discriminator axis equals kind.
Composes on top of kube_kind_is (2902d9d) — same one-hop
.get(KUBE_KEY_KIND).and_then(as_str) == Some(kind) predicate —
and closes the “find the one document of a given kind inside a
multi-doc mesh emission” navigator axis every per-Aplicacao
renderer’s post-emit test harness reaches for to split the
emitted sequence by CRD-kind before probing a per-CR body-axis.
The canonical shape 14 test-side
docs.iter().find(|d| kube_kind_is(d, <KIND>))call sites in caixa-mesh’s gateway_routes +
cilium_network_policies test harnesses previously threaded the
three-token .iter().find(closure) combinator chain around a
one-token semantic payload (the <KIND> axis-value —
GATEWAY_API_KIND_GATEWAY on the per-Gateway navigator sites,
GATEWAY_API_KIND_HTTP_ROUTE on the per-HTTPRoute navigator
sites). The lift collapses the three-token chain — the .iter()
receiver-widen, the .find(closure) combinator, the inline
closure wrap around kube_kind_is — onto one navigator
function the caller reads as intent (find_by_kind(&docs, <KIND>) — “give me the K8s CR document of kind <KIND>”)
rather than as a receiver-widen → combinator → predicate chain.
Composition-symmetric to kube_kind_is: the lifted predicate
answers “does this one document match kind <KIND>?”, the
lifted navigator answers “find the one document of kind
<KIND> in this list?”. Same axis, different arity — the two
call shapes emit-side test harnesses reach for when splitting
multi-doc CR emissions by top-level kind.
Every future per-CRD-kind multi-doc-navigator site (the
per-:politicas CiliumClusterwideEnvoyConfig emitter’s post-
emit test harness, MESH-COMPOSITION §III.2 #3; the
app-operator’s mesh.pleme.io/v1alpha1/Aplicacao CR
materializer’s per-status doc-navigator, §III.2 #5; the M4
cross-cluster fan-out’s per-cluster multi-doc split by kind)
reaches the same helper by construction, with no inline
.iter().find(closure) combinator chain and no drift surface
on the receiver-widen or combinator axes.