diff --git a/examples/kubectl.rs b/examples/kubectl.rs index 5e1d3a617..55c3067e8 100644 --- a/examples/kubectl.rs +++ b/examples/kubectl.rs @@ -62,12 +62,7 @@ fn resolve_api_resource(discovery: &Discovery, name: &str) -> Option<(ApiResourc // this is equivalent to kubectl's api group preference discovery .groups() - .flat_map(|group| { - group - .recommended_resources() - .into_iter() - .map(move |res| (group, res)) - }) + .flat_map(|group| group.resources().into_iter().map(move |res| (group, res))) .filter(|(_, (res, _))| { // match on both resource name and kind name // ideally we should allow shortname matches as well diff --git a/kube-client/src/discovery/apigroup.rs b/kube-client/src/discovery/apigroup.rs index d1a7b6a4c..6925a45d8 100644 --- a/kube-client/src/discovery/apigroup.rs +++ b/kube-client/src/discovery/apigroup.rs @@ -8,7 +8,6 @@ use kube_core::{ }; use std::cmp::Reverse; - /// Describes one API groups collected resources and capabilities. /// /// Each `ApiGroup` contains all data pinned to a each version. @@ -217,6 +216,15 @@ impl ApiGroup { .unwrap_or_default() } + /// Returns all the resources in the group. + pub fn resources(&self) -> Vec<(ApiResource, ApiCapabilities)> { + let mut r: Vec<(ApiResource, ApiCapabilities)> = vec![]; + for item in self.data.iter() { + r.append(&mut item.resources.clone()); + } + return r; + } + /// Returns the recommended (preferred or latest) versioned resources in the group /// /// ```no_run