Skip to content

Commit

Permalink
fix with the same method in kubernetes
Browse files Browse the repository at this point in the history
Signed-off-by: wbc6080 <[email protected]>
  • Loading branch information
wbc6080 committed Oct 10, 2024
1 parent 996152a commit 64c28d4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 871 deletions.
27 changes: 0 additions & 27 deletions LICENSES/vendor/github.com/gertd/go-pluralize/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/gertd/go-pluralize v0.2.1
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.0.5 // indirect
github.com/go-logr/logr v1.4.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,6 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw=
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlLgiA=
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
Expand Down
24 changes: 17 additions & 7 deletions pkg/metaserver/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"strings"

pluralize "github.com/gertd/go-pluralize"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -62,11 +61,17 @@ func UnsafeResourceToKind(r string) string {
if v, isUnusual := unusualResourceToKind[r]; isUnusual {
return v
}
pluralizeClient := pluralize.NewClient()
caser := cases.Title(language.Und)
k := caser.String(r)
// Convert plural English words to singular form
return pluralizeClient.Singular(k)
switch {
case strings.HasSuffix(k, "ies"):
return strings.TrimSuffix(k, "ies") + "y"
case strings.HasSuffix(k, "ses"):
return strings.TrimSuffix(k, "es")
case strings.HasSuffix(k, "s"):
return strings.TrimSuffix(k, "s")
}
return k
}

func UnsafeKindToResource(k string) string {
Expand All @@ -84,9 +89,14 @@ func UnsafeKindToResource(k string) string {
return v
}
r := strings.ToLower(k)
pluralizeClient := pluralize.NewClient()
// Convert English words from singular to plural form
return pluralizeClient.Plural(r)
switch string(r[len(r)-1]) {
case "s":
return r + "es"
case "y":
return strings.TrimSuffix(r, "y") + "ies"
}

return r + "s"
}

func UnstructuredAttr(obj runtime.Object) (labels.Set, fields.Set, error) {
Expand Down
22 changes: 0 additions & 22 deletions vendor/github.com/gertd/go-pluralize/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions vendor/github.com/gertd/go-pluralize/.travis.yml

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/github.com/gertd/go-pluralize/LICENSE

This file was deleted.

151 changes: 0 additions & 151 deletions vendor/github.com/gertd/go-pluralize/Makefile

This file was deleted.

Loading

0 comments on commit 64c28d4

Please sign in to comment.