kube_fake_client/lib.rs
1//! In-memory Kubernetes client for testing controllers and operators.
2//!
3//! Based on controller-runtime's fake client from the Go ecosystem.
4//!
5//! # Examples
6//!
7//! ## Namespaced Resources
8//!
9//! ```rust
10//! use kube_fake_client::ClientBuilder;
11//! use k8s_openapi::api::core::v1::Pod;
12//! use kube::api::{Api, PostParams};
13//!
14//! # #[tokio::main]
15//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//! let client = ClientBuilder::new().build().await?;
17//! let pods: Api<Pod> = Api::namespaced(client, "default");
18//!
19//! let mut pod = Pod::default();
20//! pod.metadata.name = Some("test-pod".to_string());
21//!
22//! pods.create(&PostParams::default(), &pod).await?;
23//! # Ok(())
24//! # }
25//! ```
26
27mod builder;
28mod client;
29mod client_utils;
30pub mod discovery;
31mod error;
32mod field_selectors;
33pub mod gen;
34pub mod interceptor;
35pub mod label_selector;
36mod mock_service;
37pub mod registry;
38mod tracker;
39mod utils;
40pub mod validator;
41
42#[cfg(test)]
43mod builder_test;
44#[cfg(test)]
45mod client_test;
46#[cfg(test)]
47mod label_selector_test;
48#[cfg(test)]
49mod mock_service_test;
50#[cfg(test)]
51mod tracker_test;
52#[cfg(test)]
53mod utils_test;
54
55pub use builder::ClientBuilder;
56pub use error::{Error, Result};
57pub use kube::Client;