Skip to main content

kube_metadata_seq_field

Function kube_metadata_seq_field 

Source
pub fn kube_metadata_seq_field<'a>(
    value: &'a Value,
    field: &str,
) -> Option<&'a Sequence>
Expand description

Read the sub-metadata.<field> YAML sequence on a K8s custom resource YAML document as Option<&serde_yaml::Sequence> — the composed sequence-arity per-sub-field-sequence accessor peer that stands on the composed scalar-arity kube_metadata_field (450f1ff) accessor, folding the trailing .and_then(|v| v.as_sequence()) shape-gate closure into the helper for callers that always want a sequence (the K8s API-machinery ObjectMeta-flavoured sub-metadata: sequence axes — metadata.ownerReferences on every controller-owned CR the GC-cascade wiring reaches through, MESH-COMPOSITION §III.2 #5; metadata.finalizers on every CR whose deletion drives an operator- side pre-delete hook; metadata.managedFields on every Server-Side-Apply-authored CR the per-field-ownership contract enumerates). Structural mirror of the sibling kube_spec_seq_field (fc64ed7) on the sub-spec.<field> axis: both accessors fold a trailing .as_sequence() shape-gate closure onto their crate’s composed scalar-arity per-sub-field-Value accessor primitive (kube_metadata_field here, kube_spec_field on the sibling), both stay parametric on the per-<field> sub-field axis-key (metadata stays open-ended on the K8s ObjectMeta-sub-field surface, spec-body stays open-ended on the K8s CRD-schema surface). Closes the three-arity shape-gate family on the sub-metadata: axis to structural parity with the sub-spec: axis: the kube_metadata_str_field scalar-string arm, this kube_metadata_seq_field sequence arm, and the kube_metadata_map_field (d03cc08) sub-mapping arm — all three now compose on the same kube_metadata_field two-hop metadata → as_mapping → get(<field>) primitive, structural mirror of serde_yaml’s own Value::{as_str, as_sequence, as_mapping} shape-gate trio on the outer Value closed over the sub- metadata: axis.

Returns None on any of the four short-circuit arms folded through the underlying composition: the outer metadata: block is absent (the kube_metadata outer-arm short-circuit — a legally-omitted per-CR identity sub-block on List-shaped documents or on external YAML shapes that carry no ObjectMeta-flavoured header), the metadata: value is present but carries a non-Mapping YAML type (the kube_metadata shape-gate short-circuit — a schema-invalid identity shape per the K8s API-machinery contract tolerated here as None so the readback stays a total function), the requested sub-field <field> axis-key is absent from the metadata: sub-mapping (the kube_metadata_field trailing Mapping::get none-arm — a legally-omitted per-metadata-axis surface on a CR that carries other identity sub-fields but not this one), or the sub-field value is present but carries a non- sequence YAML type (the trailing .as_sequence() shape-gate short-circuit — a schema-invalid per-CR identity-sub-field type per the K8s apiserver’s OpenAPI schema but tolerated here as None so the readback stays a total function). The returned &Sequence borrows into the input Value — the caller decides whether to iterate (.iter()), pick the first entry (.first()), enumerate for length (.len()), or clone.

The field axis stays parametric (rather than pinned to a specific canonical sub-field like metadata.ownerReferences as a separate helper) because the K8s API-machinery ObjectMeta contract admits an open-ended per-CR identity sequence-field surface — one helper covers every sequence-shaped ObjectMeta axis today (metadata.ownerReferences for GC-cascade wiring, metadata.finalizers for pre-delete-hook coordination, metadata.managedFields for per-field-ownership enumeration under Server-Side-Apply) with the axis-key threaded through the call. Every future per-CR metadata.<field> sequence readback (the app-operator’s per-Aplicacao mesh.pleme.io/v1alpha1/Aplicacao CR materializer’s metadata.ownerReferences readback for controller-owned GC-cascade wiring, MESH-COMPOSITION §III.2 #5; the future caixa-operator’s per-Caixa/Lacre/CaixaBuild CR metadata.finalizers navigation for the build-lifecycle pre- delete-hook contract; every future test-side metadata.<field>[] sequence probe the M3.x + M4 renderer set adds) reaches this same helper by construction — no per-consumer three-hop chain re- inline, no per-consumer KUBE_KEY_METADATA axis-key drift, no coordinated rewrite across every per-CR identity-sub-field sequence readback on a future K8s API-machinery rebrand of the top-level metadata: axis.