A kubernetes openapi unmangler.
Creates rust structs from a named crd by converting the live openapi schema.
⚠️ WARNING: ALPHA SOFTWARE ⚠️
sh
cargo install kopium
sh
kopium prometheusrules.monitoring.coreos.com > prometheusrule.rs
rustfmt +nightly --edition 2021 prometheusrule.rs
```rust use kube::CustomResource; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap;
group = "monitoring.coreos.com",
version = "v1",
kind = "PrometheusRule",
plural = "prometheusrules"
)]
pub struct PrometheusRuleSpec {
#[serde(default, skipserializingif = "Vec::is_empty")]
pub groups: Vec
pub struct PrometheusRuleGroups {
pub interval: Option
pub struct PrometheusRuleRules {
pub alert: Option
Generate a CRD, tell the test runner to try to use it.
sh
cargo run --bin kopium -- prometheusrules.monitoring.coreos.com > tests/gen.rs
echo "pub type CR = PrometheusRule;" >> tests/gen.rs
kubectl apply -f tests/pr.yaml # needs to contain a CR with name "gen"
cargo test --test runner -- --nocapture
Requires kubernetes access to write customresourcedefinitions.