You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inflector is no longer maintained. It's a large dependency, and we don't use most of its features (just to_plural). We should be able to replace it with a much simpler function by not trying to handle the irregulars. Inflector is buggy anyway (see #467).
Here's a Rust port of a popular JavaScript package plur minus the irregular and case matching.
fnto_plural(word:&str) -> String{// Words ending in s, x, z, ch, sh will be pluralized with -es (eg. foxes).if word.ends_with('s')
|| word.ends_with('x')
|| word.ends_with('z')
|| word.ends_with("ch")
|| word.ends_with("sh"){returnformat!("{}es", word);}// Words ending in y that are preceded by a consonant will be pluralized by// replacing y with -ies (eg. puppies).if word.ends_with('y'){ifletSome(c) = word.chars().nth(word.len() - 2){if !matches!(c,'a' | 'e' | 'i' | 'o' | 'u'){// Remove 'y' and add `ies`letmut chars = word.chars();
chars.next_back();returnformat!("{}ies", chars.as_str());}}}// All other words will have "s" added to the end (eg. days).format!("{}s", word)}
One concern is that this is not idempotent. (e.g., Endpoints. See #284 (comment)). We can special-case the native failures, and custom resource can specify irregular.
I think a small helper to deal with this from a kube POV for now makes sense.
It lets us handle the special cases, and it'll give us a less heavy dependency, that's also probably better with its memory management: #14 (comment)
The pascal case helper doesn't do anything useful anymore so can just remove those lines.
Inflector is no longer maintained. It's a large dependency, and we don't use most of its features (just
to_plural
). We should be able to replace it with a much simpler function by not trying to handle the irregulars. Inflector is buggy anyway (see #467).Here's a Rust port of a popular JavaScript package plur minus the irregular and case matching.
One concern is that this is not idempotent. (e.g.,
Endpoints
. See #284 (comment)). We can special-case the native failures, and custom resource can specify irregular.is_pascal_case
is also used:https://github.com/clux/kube-rs/blob/813da82a5924ca54829689eae9b88e2cef465494/kube/src/api/dynamic.rs#L171-L176
but I believe it should be removed.
kube-derive
side was removed 7187db7The text was updated successfully, but these errors were encountered: