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

🐛 Fix plural #1090

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Member

@camilamacedo86 camilamacedo86 Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to ask for we think a lot before change this one.
-1 for this change.

My 2 cents is that it can broke the projects built so far and kubebuilder integration,
see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/model/resource/utils.go#L59-L62

I think the answer here would be the same of: kubernetes-sigs/kubebuilder#3402 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/hold

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. We can't make a change that leads to any different names here

}

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