diff --git a/examples/dynamic_watcher.rs b/examples/dynamic_watcher.rs index ad5c42c3f..a903e8dd5 100644 --- a/examples/dynamic_watcher.rs +++ b/examples/dynamic_watcher.rs @@ -19,7 +19,17 @@ async fn main() -> anyhow::Result<()> { // Turn them into a GVK let gvk = GroupVersionKind::gvk(&group, &version, &kind); - let api_resource = ApiResource::from_gvk(&gvk); + let mut api_resource = ApiResource::from_gvk(&gvk); + + if let Some(resource) = env::var("RESOURCE").ok() { + api_resource.plural = resource; + } else { + println!( + "Using inferred plural name (use RESOURCE to override): {}", + api_resource.plural + ); + } + // Use them in an Api with the GVK as its DynamicType let api = Api::::all_with(client, &api_resource); diff --git a/kube/src/api/gvk.rs b/kube/src/api/gvk.rs index 9dacf4be4..be61b664d 100644 --- a/kube/src/api/gvk.rs +++ b/kube/src/api/gvk.rs @@ -47,7 +47,7 @@ impl GroupVersionResource { } else { format!("{}/{}", group, version) }; - + Self { group, version,