Closed matthiasvegh closed 3 months ago
Thanks for the nicely written issue! I've fixed this up in #464.
I really appreciate the small reproducer you included, and digging into the code a little to highlight functions that are problematic. It made it super quick to add a small failing test that highlighted the bug, and then put in a quick fix to get the test passing.
The fix for this is included in v0.17.1.
Which project are you reporting a bug for?
kr8s
What happened?
Resources whose singular name ends with y appear to be pluralized naively by adding an s. This makes it impossible to get them using kr8s. Whereas
kubectl get
works without issue:In my program, I don't actually wish to interact much with the objects themselves, I merely wish to list all objects (of any kind) that matches a particular label-selector and delete them akin to:
As such, registering the classes that may appear in my cluster is not really practical. As of #432, I thought I wouldn't need to, and could just take advantage of kr8s' excellent async functionality.
However, it appears that resource names that end in y cause kr8s to choke, unless it's a Kind already known by kr8s like NetworkPolicy. I'm using CSIStorageCapacity as an example below as I think that is universal enough to not just be on my cluster. In practice, I have a lot of resources of the form CertificateAuthority, InternalOAuth2Identity, HTTPProxy, etc, nor can I workaround the issue by supplying the plural name instead of the singular name, as kr8s internally looks it up again, and uses the Kind instead of the name I supplied.
Based on the error messages produced, it appears that the path computed simply appends an s to the singularName, ending in 404s, note
csistoragecapacitys
:Digging a bit into the code, it appears that the logic to pluralize is in
new_class
which could accept a plural form (which appears to have been worked on in #403). Unfortunately,async_get_kind
only passeskind
, andnamespaced
but notplural
. Perhapsasync_lookup_kind
could return both names?Anything else?
kr8s version: 0.17.0 python version 3.10
my program: