pub fn singleton_mapping_sequence(m: Mapping) -> ValueExpand description
Wrap a single serde_yaml::Mapping as the sole element of a
serde_yaml::Value::Sequence, returning the ready-to-drop
singleton-mapping-sequence Value.
The canonical shape every K8s-CRD schema-list-shape-required field
with exactly one entry to emit lands the same
Value::Sequence(vec![Value::Mapping(m)]) three-token block in
front of. Seven identical-shape call sites across
caixa-mesh collapse onto this helper:
- Cilium
CiliumNetworkPolicy.spec.ingress[].toPorts[].ports(oneport_entryper typed edge, wrapped in the CRD’s required-list-shapeports:axis); - Cilium
CiliumNetworkPolicy.spec.ingress[].toPorts[].rules.http(onehttp_ruleper L7-introspection-capablecrate::WitTarget::Httpcontract, wrapped in the CRD’s required-list-shapehttp:axis); - Cilium
CiliumNetworkPolicy.spec.ingress(oneingress_ruleper policy — Cilium’s CRD schema lists the per-policy ingress ruleset even though V0 emits exactly one entry); - Gateway API
Gateway.spec.listeners(onelistenerper Gateway — V0 emits the single HTTP-listener shape the siblingGATEWAY_API_DEFAULT_HTTP_LISTENER_NAME+GATEWAY_API_DEFAULT_HTTP_LISTENER_PORTconsts pin); - Gateway API
HTTPRoute.spec.rules[].matches(onematch_entryper rule — V0 emits a single per-path prefix-match); - Gateway API
HTTPRoute.spec.rules[].backendRefs(onebackend_refper rule — V0 emits a single-backend fan-in on the:entrada :paradestination Servico); - Gateway API
HTTPRoute.spec.parentRefs(oneparent_refper route — every route attaches to exactly one Gateway).
Until this lift landed all seven call sites re-inlined the same
three-token boilerplate — serde_yaml:: path re-quote,
Value::Sequence(_) promotion, vec![serde_yaml::Value::Mapping(_)]
singleton-list wrapping — around a one-token semantic payload (the
per-site Mapping). Lifting collapses the boilerplate into one
function call the caller reads as intent (singleton_mapping_sequence (<mapping>) — “wrap this single mapping as the CRD-required list-
shape”) rather than three hand-spelled positional artifacts. The
next renderer to land — the per-:politicas
CiliumClusterwideEnvoyConfig emitter (MESH-COMPOSITION §III.2 #3,
which drops singleton resources:[] / listeners:[] /
virtualHosts:[] blocks under its per-policy CR spec), the
app-operator’s typed mesh.pleme.io/v1alpha1/Aplicacao CR
materializer (§III.2 #5, whose spec.selectors:[] / spec.gates:[]
blocks list-shape a single per-Aplicacao entry), the M4 cross-
cluster fan-out’s per-cluster Service.spec.ports[] /
HTTPRoute.spec.rules[].backendRefs[] emission, the future
caixa-otel OpenTelemetry-Collector pipelines.traces.receivers[]
/ pipelines.traces.exporters[] singleton-list-shape emission —
gets the canonical CRD-list-shape-wrap for free with one function
call, instead of re-inlining the same three-token block. Peer with
the sibling render-side helpers on the serde_yaml::Value-
construction surface (yaml_string_mapping, label_selector,
kube_resource_skeleton, single_field_overlay, the sibling
MappingExt::insert_str_key primitive) — each closes a distinct
axis of the K8s-artifact-emit surface’s “same shape, written N
times” duplication.
The helper takes an owned serde_yaml::Mapping (moving into the
wrapping vec! without a clone) because every call site has just
finished building the mapping locally and passes it by value to the
insert-under-outer-key step. A [Value::Mapping] wrapping of the
same mapping is one step further along the emit trajectory — the
helper closes the gap in one primitive.
The seven caixa-mesh call sites all followed the same
insert-under-outer-key step, so the composition
mapping.insert_str_key(K, singleton_mapping_sequence(m)) is
itself lifted onto the sibling MappingExt::insert_singleton_mapping_sequence
method — every caixa-mesh site now reaches for the composed
method rather than nesting the two calls at the call site. This
standalone helper remains the semantic primitive for the
singleton-Mapping-list-shape Value (the trait method’s impl
composes it internally), and stays public for future callers that
want the raw Value::Sequence(vec![Value::Mapping(m)]) payload
without inserting it under a schema key.