Build the opaque `platform_config` Struct from platform-specific public template fields (`runtime_class_name`, annotations) plus any resource fields beyond CPU/memory.
(template: &SandboxTemplate)
| 1669 | /// template fields (`runtime_class_name`, annotations) plus any resource fields |
| 1670 | /// beyond CPU/memory. |
| 1671 | fn build_platform_config(template: &SandboxTemplate) -> Option<prost_types::Struct> { |
| 1672 | use prost_types::{Struct, Value, value::Kind}; |
| 1673 | |
| 1674 | let mut fields = std::collections::BTreeMap::new(); |
| 1675 | |
| 1676 | if !template.runtime_class_name.is_empty() { |
| 1677 | fields.insert( |
| 1678 | "runtime_class_name".to_string(), |
| 1679 | Value { |
| 1680 | kind: Some(Kind::StringValue(template.runtime_class_name.clone())), |
| 1681 | }, |
| 1682 | ); |
| 1683 | } |
| 1684 | |
| 1685 | if !template.annotations.is_empty() { |
| 1686 | let annotation_fields = template |
| 1687 | .annotations |
| 1688 | .iter() |
| 1689 | .map(|(k, v)| { |
| 1690 | ( |
| 1691 | k.clone(), |
| 1692 | Value { |
| 1693 | kind: Some(Kind::StringValue(v.clone())), |
| 1694 | }, |
| 1695 | ) |
| 1696 | }) |
| 1697 | .collect(); |
| 1698 | fields.insert( |
| 1699 | "annotations".to_string(), |
| 1700 | Value { |
| 1701 | kind: Some(Kind::StructValue(Struct { |
| 1702 | fields: annotation_fields, |
| 1703 | })), |
| 1704 | }, |
| 1705 | ); |
| 1706 | } |
| 1707 | |
| 1708 | // Invert: the public API uses `user_namespaces: true` (positive sense) |
| 1709 | // while the K8s driver expects `host_users: false` (K8s convention). |
| 1710 | // The driver inverts this back via `!host_users` to resolve the final |
| 1711 | // pod-level `hostUsers` field. |
| 1712 | if let Some(user_ns) = template.user_namespaces { |
| 1713 | fields.insert( |
| 1714 | "host_users".to_string(), |
| 1715 | Value { |
| 1716 | kind: Some(Kind::BoolValue(!user_ns)), |
| 1717 | }, |
| 1718 | ); |
| 1719 | } |
| 1720 | |
| 1721 | // Pass through any resource fields that do not map to the typed |
| 1722 | // DriverResourceRequirements so platform-specific drivers can still see |
| 1723 | // custom resources such as GPU limits. |
| 1724 | if let Some(res) = build_platform_resources_config(&template.resources) { |
| 1725 | fields.insert( |
| 1726 | "resources_raw".to_string(), |
| 1727 | Value { |
| 1728 | kind: Some(Kind::StructValue(res)), |