Skip to content

Commit

Permalink
fix plural
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtvgf committed Nov 10, 2024
1 parent 9691d19 commit 619ad17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/fatih/color v1.18.0
github.com/gobuffalo/flect v1.0.3
github.com/google/go-cmp v0.6.0
github.com/jinzhu/inflection v1.0.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.35.1
github.com/spf13/cobra v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAx
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
4 changes: 2 additions & 2 deletions pkg/crd/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"sort"
"strings"

"github.com/gobuffalo/flect"
"github.com/jinzhu/inflection"

apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -63,7 +63,7 @@ func (p *Parser) NeedCRDFor(groupKind schema.GroupKind, maxDescLen *int) {
packages = append(packages, pkg)
}

defaultPlural := strings.ToLower(flect.Pluralize(groupKind.Kind))
defaultPlural := strings.ToLower(inflection.Plural(groupKind.Kind))
crd := apiext.CustomResourceDefinition{
TypeMeta: metav1.TypeMeta{
APIVersion: apiext.SchemeGroupVersion.String(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/typescaffold/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"strings"

"github.com/gobuffalo/flect"
"github.com/jinzhu/inflection"
)

// Resource contains the information required to scaffold files for a resource.
Expand All @@ -42,7 +43,7 @@ func (r *Resource) Validate() error {
}

if len(r.Resource) == 0 {
r.Resource = flect.Pluralize(strings.ToLower(r.Kind))
r.Resource = inflection.Plural(strings.ToLower(r.Kind))
}

if r.Kind != flect.Pascalize(r.Kind) {
Expand Down

0 comments on commit 619ad17

Please sign in to comment.