Skip to main content

Crate engenho_kube_codegen

Crate engenho_kube_codegen 

Source
Expand description

§engenho-kube-codegen

Reads vendored Kubernetes OpenAPI v3 JSON + emits typed Rust source into engenho-types/src/generated_v1_34/. The load-bearing invariant: no hand-authored K8s resource types — every kind is generated bit-reproducibly from upstream.

§What’s generated today (M0.0.1 first pass)

A “thin kind” representation: each generated struct carries:

  • metadata: engenho_types::meta::ObjectMeta
  • spec: serde_json::Value (typed expansion is M0.0.4)
  • status: Option<serde_json::Value>

Plus a KubeResource impl with the correct GroupVersionKind / GroupVersionResource / Scope.

§Future (M0.0.4)

Recursive $ref expansion through the OpenAPI spec produces fully-typed PodSpec, Container, Volume, etc. Hand-rolled ObjectMeta also becomes generator output at that point.

§Determinism contract

kube-codegen --check (callable from CI) must regenerate byte-identical source from the same input. Implementation:

  • Sort iteration deterministic (BTreeMap, never HashMap).
  • Emitted source has a fixed header comment.
  • Field ordering: required-then-optional, then alphabetical.

Re-exports§

pub use catalog::KIND_CATALOG;
pub use catalog::KindEntry;
pub use catalog::Subresource;
pub use emit::emit_catalog;
pub use emit::emit_kind;
pub use emit::emit_kind_typed;
pub use emit::emit_module;
pub use emit::emit_shared_module;
pub use emit_blue::emit_blue_kinds;
pub use emit_typed::SchemaView;
pub use emit_typed::shared_substructs;
pub use openapi::KindShape;
pub use openapi::OpenApiDoc;

Modules§

catalog
Curated catalog of K8s kinds to generate in the M0.0.1 first pass.
emit
Source emitters — typed config → Rust source string.
emit_blue
emit_typed
Typed-struct emission engine (M0.0.4 brick 2).
openapi
OpenAPI v3 parser — sufficient surface to extract a “kind shape” per crate::catalog::KindEntry.
schemas
types
OpenAPI v3 schema → Rust type mapping (the M0.0.4 typed-emission core).

Functions§

format_source
Format emitted Rust source, deterministically and without a subprocess.