1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! # 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.
pub use ;
pub use ;
pub use emit_blue_kinds;
pub use ;
pub use ;
/// Format emitted Rust source, deterministically and without a subprocess.
///
/// ## Why this exists
///
/// The generator emitted UNFORMATTED source while the committed files were
/// formatted. Measured 2026-08-30: `--check` reported 46 drifting files
/// against a pristine tree, and **40 of them differed by formatting alone**
/// — reformatted by `16d0fd5`, a workspace-wide `cargo fmt` that swept 149
/// files including this generated directory.
///
/// A determinism gate that is permanently red is not a gate. Once
/// `--check` could never pass, nobody could see the SIX real differences
/// hiding behind the forty cosmetic ones — including three hand-authored
/// files (`rbac_v1/policy.rs`, `apps_v1/deployment_spec.rs`,
/// `apps_v1/replicaset_spec.rs`) living inside a directory whose header
/// says GENERATED — DO NOT EDIT. Regenerating deletes them, which is
/// exactly how a routine regen broke `engenho-apiserver`'s authz module.
///
/// ## Why prettyplease and not rustfmt
///
/// `--check` compares bytes, so the formatter must be pinned by Cargo, not
/// by whatever `rustfmt` is on the operator's PATH. A subprocess would also
/// be a shell-out in a codebase that forbids them. `prettyplease` is a
/// library, versioned in the lockfile, identical on every machine.
///
/// # Errors
///
/// Returns the parse error if `src` is not valid Rust. This fails LOUDLY
/// on purpose: a generator emitting unparseable source is a defect, and
/// silently writing it out would move the failure to whoever builds next.