Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update KindToResource impl to match API server #6851

Closed
liggitt opened this issue Jan 27, 2016 · 0 comments · Fixed by #6873
Closed

Update KindToResource impl to match API server #6851

liggitt opened this issue Jan 27, 2016 · 0 comments · Fixed by #6873

Comments

@liggitt
Copy link
Contributor

liggitt commented Jan 27, 2016

k8s PR 16221 upstream changed KindToResource handling of kinds ending in "s", so we'll need to carry an exception for "securitycontextconstraints" and match this impl:

// KindToResource converts Kind to a resource name.
func KindToResource(kind string, mixedCase bool) (plural, singular string) {
    if len(kind) == 0 {
        return
    }
    if mixedCase {
        // Legacy support for mixed case names
        singular = strings.ToLower(kind[:1]) + kind[1:]
    } else {
        singular = strings.ToLower(kind)
    }
    if strings.HasSuffix(singular, "endpoints") || strings.HasSuffix(singular, "securitycontextconstraints") {
        plural = singular
    } else {
        switch string(singular[len(singular)-1]) {
        case "s":
            plural = singular + "es"
        case "y":
            plural = strings.TrimSuffix(singular, "y") + "ies"
        default:
            plural = singular + "s"
        }
    }
    return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants