Skip to content

Commit

Permalink
Update dynamic watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
MikailBag committed Apr 20, 2021
1 parent 958e81b commit 2894576
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion examples/dynamic_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DynamicObject>::all_with(client, &api_resource);

Expand Down
2 changes: 1 addition & 1 deletion kube/src/api/gvk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl GroupVersionResource {
} else {
format!("{}/{}", group, version)
};

Self {
group,
version,
Expand Down

0 comments on commit 2894576

Please sign in to comment.