Skip to main content

kube_field_seq

Function kube_field_seq 

Source
pub fn kube_field_seq<'a, R: KubeReceiver + ?Sized>(
    recv: &'a R,
    field: &str,
    seq_field: &str,
) -> Option<&'a Sequence>
Expand description

Read a sub-<mid>.<tail>[] YAML sequence nested two hops under an arbitrary KubeReceiver as Option<&serde_yaml::Sequence> — the value-level three-hop navigation primitive that folds .get(<mid>) .and_then(|v| v.get(<tail>)).and_then(|v| v.as_sequence()) into a single helper call. Exactly kube_field(recv, mid).and_then(|v| kube_seq(v, tail)) — the composed peer of the value-level kube_field (e04c234) one-hop pass-through and the value-level sequence-arity kube_seq (9c74ddb) two-hop accessor. Sequence- arity sibling of the composed scalar-str kube_field_str (1c68424), composed scalar-u64 kube_field_u64 (e6fca52), and composed scalar-bool kube_field_bool (261894b) accessors on the same three-hop axis: where those composed accessors fold a trailing .as_str() / .as_u64() / .as_bool() shape-gate onto the two-hop-nested navigation, this accessor folds the trailing .as_sequence() shape-gate on the same navigation, so every routed two-hop .and_then(|X| kube_field(X, <MID>)).and_then(|Y| kube_seq (Y, <TAIL>)) middle-hop-plus-sequence-tail block (per-CNP spec.ingress[<i>].toPorts[<j>].rules.http L7 HTTP-rule-list read on the Cilium side, per-HTTPRoute future spec.rules[<i>] .matches[<j>].headers per-match header-predicate-list read once the header-match overlay lands, per-HelmRelease future spec.postRenderers.kustomize.patches per-CR post-render patch- list read once the postRenderers overlay lifts) folds onto one dispatch.

Returns None on any of the four short-circuit arms folded through the underlying three-hop composition: the receiver carries a YAML type without a get(<mid>) navigation surface (serde_yaml::Value::get returns None on scalar arms — string, bool, number, null — that expose no per-key lookup), the requested <mid> middle-hop axis-key is absent from the receiver’s mapping, the <mid> sub-field value is present but carries a YAML shape with no get(<tail>) navigation surface (a scalar arm at the middle-hop altitude — the inner serde_yaml::Value::get scalar-arm None folds through), or the <tail> value is present but carries a non- sequence YAML type (the trailing .as_sequence() shape-gate short- circuit — a schema-invalid nested type per the K8s apiserver’s OpenAPI schema but tolerated here as None so the readback stays a total function, mirroring the sibling kube_field_str / kube_field_u64 / kube_field_bool posture). The returned &Sequence borrows into the input receiver — the caller decides whether to .iter() for a per-entry walk, .len() for a length assertion, .is_empty() for an emptiness probe, or .expect(...) for a load-bearing full-sequence bind.

The canonical shape 1 test-side per-nested-<mid>.<tail>[] sequence readback site in caixa-mesh (the per-CNP spec.ingress[0].toPorts[0].rules.http L7-HTTP-rule-list-container readback keyed on crate::KUBE_KEY_RULES middle-hop and crate::CILIUM_KEY_HTTP sequence-tail — the per-toPorts[] L7-HTTP-rule-list container Cilium §L7 partitions the per-CNP L7 URL-path predicate list across, chained below the outer kube_spec_seq_first_seq_first two-hop-nested spec.ingress[0] .toPorts[0] bracket the routed cilium_http_contracts_emit_l7_rules determinism pin walks) previously carried inline as the two-line middle-hop-plus-sequence-tail block

<value>
    .and_then(|X| kube_field(X, <MID>))
    .and_then(|Y| kube_seq(Y, <TAIL>))
    ...

After this lift every routed consumer folds the two-line composition onto kube_field_seq(<value>, <MID>, <TAIL>) — the three-hop get → get → as_sequence walk happens once inside the helper, and the caller keeps its downstream posture (.iter(), .len(), .is_empty(), .expect(...), an if let Some(s) = _ bind) unchanged — the lift closes the navigation surface, not the per- site downstream posture. Closes the composed value-level shape- gated family at the fourth of the value-level primitive arities the sibling kube_field_str opened at the string arity, the sibling kube_field_u64 closed at the integer arity, and the sibling kube_field_bool closed at the boolean arity — the remaining sub-mapping-arity peer kube_field_map closes the last shape- gate arity, matching the closed shape of the value-level primitive family (kube_field, kube_str, kube_u64, kube_bool, kube_seq, kube_map) one altitude below where the shape- gated variants already span the axis. Alongside the composed raw- tail kube_field_field (cb5d862) peer this now spans the composed value-level three-hop navigation surface at every arity the K8s apiserver OpenAPI schema partitions on at the sequence altitude — raw-Value via kube_field_field, sequence via kube_field_seq.

Every future nested <mid>.<tail>[] sequence readback the M3.x + M4 renderer set materializes (the future per-:contratos per-edge WIT-attribute nested sub-sequence once the M4 typed per-edge overlay lands, the future per-Aplicacao spec.placement.affinity.nodeAffinity[] nested node-affinity list readback under a placement-shape probe, the future caixa-otel per-Servico per-processors.<name>.filters[] nested processor- filter-list probe, every future test-side nested-[] sequence readback the M3.x + M4 renderer set adds under .iter() / .len() / .is_empty() enumeration) reaches this one helper by construction. No per-consumer two-hop re-inline; no coordinated rewrite across every nested-sequence readback on a future serde_yaml surface rebrand or shape-gate shift.