Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPSTREAM: 91295: kubectl explain: detect resource group in case there…
… are two or more groups discovered Assume the following CRDs exist (ordered by priority, the first is the highest): - authentications.migration.k8s.io (K=Authentications, G=migration.k8s.io) - authentications.metal3.io (K=Authentications, G=metal3.io) - authentications.whereabouts.cni.cncf.io (K=Authentications, G=whereabouts.cni.cncf.io) - authentications.snapshot.storage.k8s.io (K=Authentications, G=snapshot.storage.k8s.io) In case 'kubectl explain authentications' is ran, the highest priority definition (in this case authentications.migration.k8s.io) is returned. In case a user wants to explain authentication CRD of a different group, --api-version flag has to be set alongside to point to a specific group and version. E.g. --api-version=metal3.io/v1 This PR allows to dismiss --api-version flag and perform a prefix check to select a resource (e.g. CRD) whose (resource, group) pair fully prefixes requested resource. E.g. running 'kubectl explain authentications.metal3.io' will return description of authentications.metal3.io. The same holds for optional field path. I.e. 'kubectl explain authentications.metal3.io.spec' will return description of spec field of authentications.metal3.io.spec. In case no resource match is found, the search falls back to selecting the highest priority gvr that matches the resource. In case --api-version is set, no prefix matching is performed. To cover cases such as 'kubectl explain authentications.metal3.io --api-version=authentications.metal3.io/v1' where fields path coincide with the resource fully specified name (to access .metal3.io field of authentications.metal3.io).
- Loading branch information