From 71237a9bd669a6b69d534188e1b1e82c0e007506 Mon Sep 17 00:00:00 2001 From: Mengqi Yu Date: Tue, 21 May 2019 16:36:16 -0700 Subject: [PATCH] :bug: fix a plural name bug --- pkg/scaffold/v2/crd/enablewebhook_patch.go | 6 +++++- .../{webhook_in_captain.yaml => webhook_in_captains.yaml} | 0 ...webhook_in_firstmate.yaml => webhook_in_firstmates.yaml} | 0 3 files changed, 5 insertions(+), 1 deletion(-) rename testdata/project-v2/config/crd/patches/{webhook_in_captain.yaml => webhook_in_captains.yaml} (100%) rename testdata/project-v2/config/crd/patches/{webhook_in_firstmate.yaml => webhook_in_firstmates.yaml} (100%) diff --git a/pkg/scaffold/v2/crd/enablewebhook_patch.go b/pkg/scaffold/v2/crd/enablewebhook_patch.go index c523bff4e9b..f2496c76ae3 100644 --- a/pkg/scaffold/v2/crd/enablewebhook_patch.go +++ b/pkg/scaffold/v2/crd/enablewebhook_patch.go @@ -21,6 +21,8 @@ import ( "path/filepath" "strings" + "github.com/markbates/inflect" + "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/v1/resource" ) @@ -36,8 +38,10 @@ type EnableWebhookPatch struct { // GetInput implements input.File func (p *EnableWebhookPatch) GetInput() (input.Input, error) { if p.Path == "" { + rs := inflect.NewDefaultRuleset() + plural := rs.Pluralize(strings.ToLower(p.Resource.Kind)) p.Path = filepath.Join("config", "crd", "patches", - fmt.Sprintf("webhook_in_%s.yaml", strings.ToLower(p.Resource.Kind))) + fmt.Sprintf("webhook_in_%s.yaml", plural)) } p.TemplateBody = enableWebhookPatchTemplate return p.Input, nil diff --git a/testdata/project-v2/config/crd/patches/webhook_in_captain.yaml b/testdata/project-v2/config/crd/patches/webhook_in_captains.yaml similarity index 100% rename from testdata/project-v2/config/crd/patches/webhook_in_captain.yaml rename to testdata/project-v2/config/crd/patches/webhook_in_captains.yaml diff --git a/testdata/project-v2/config/crd/patches/webhook_in_firstmate.yaml b/testdata/project-v2/config/crd/patches/webhook_in_firstmates.yaml similarity index 100% rename from testdata/project-v2/config/crd/patches/webhook_in_firstmate.yaml rename to testdata/project-v2/config/crd/patches/webhook_in_firstmates.yaml