From 4b3940cbbd26c6e64348166feaf5af084018beb6 Mon Sep 17 00:00:00 2001 From: Mengqi Yu Date: Mon, 6 May 2019 17:16:14 -0700 Subject: [PATCH] :sparkles: stop using k8s.io/apimachinery to convert kind to resource --- cmd/webhook.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/webhook.go b/cmd/webhook.go index f1820ba6eab..5f4e0cb04d3 100644 --- a/cmd/webhook.go +++ b/cmd/webhook.go @@ -21,12 +21,12 @@ import ( "log" "os" "os/exec" + "strings" + "github.com/markbates/inflect" "github.com/spf13/cobra" flag "github.com/spf13/pflag" - "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/kubebuilder/pkg/scaffold" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/project" @@ -64,9 +64,7 @@ Scaffolds webhook handlers based on group, version, kind and other user inputs. fmt.Println("Writing scaffold for you to edit...") if len(o.res.Resource) == 0 { - gvr, _ := meta.UnsafeGuessKindToResource(schema.GroupVersionKind{ - Group: o.res.Group, Version: o.res.Version, Kind: o.res.Kind}) - o.res.Resource = gvr.Resource + o.res.Resource = inflect.NewDefaultRuleset().Pluralize(strings.ToLower(o.res.Kind)) } err = (&scaffold.Scaffold{}).Execute(input.Options{},