-
-
Notifications
You must be signed in to change notification settings - Fork 380
Open
Labels
coregeneric apimachinery style workgeneric apimachinery style work
Description
Would you like to work on this feature?
No response
What problem are you trying to solve?
Use shortnames like kubectl request
Describe the solution you'd like
support shortname in resolve_api_resource function
fn resolve_api_resource(
discovery: &Discovery,
name: &str,
) -> Option<(ApiResource, ApiCapabilities)> {
// iterate through groups to find matching kind/plural names at recommended versions
// and then take the minimal match by group.name (equivalent to sorting groups by group.name).
// this is equivalent to kubectl's api group preference
discovery
.groups()
.flat_map(|group| {
group
.recommended_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
name.eq_ignore_ascii_case(&res.kind) || name.eq_ignore_ascii_case(&res.plural)
})
.min_by_key(|(group, _res)| group.name())
.map(|(_, res)| res)
}Describe alternatives you've considered
Not yet.
Documentation, Adoption, Migration Strategy
No response
Target crate for feature
kube-core
Metadata
Metadata
Assignees
Labels
coregeneric apimachinery style workgeneric apimachinery style work