Skip to content

Commit 7fd5cf6

Browse files
authored
Merge pull request #685 from mengqiy/kind2resources
✨ stop using k8s.io/apimachinery to convert kind to resource
2 parents f34de3b + 4b3940c commit 7fd5cf6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cmd/webhook.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"log"
2222
"os"
2323
"os/exec"
24+
"strings"
2425

26+
"github.com/markbates/inflect"
2527
"github.com/spf13/cobra"
2628
flag "github.com/spf13/pflag"
2729

28-
"k8s.io/apimachinery/pkg/api/meta"
29-
"k8s.io/apimachinery/pkg/runtime/schema"
3030
"sigs.k8s.io/kubebuilder/pkg/scaffold"
3131
"sigs.k8s.io/kubebuilder/pkg/scaffold/input"
3232
"sigs.k8s.io/kubebuilder/pkg/scaffold/project"
@@ -64,9 +64,7 @@ Scaffolds webhook handlers based on group, version, kind and other user inputs.
6464
fmt.Println("Writing scaffold for you to edit...")
6565

6666
if len(o.res.Resource) == 0 {
67-
gvr, _ := meta.UnsafeGuessKindToResource(schema.GroupVersionKind{
68-
Group: o.res.Group, Version: o.res.Version, Kind: o.res.Kind})
69-
o.res.Resource = gvr.Resource
67+
o.res.Resource = inflect.NewDefaultRuleset().Pluralize(strings.ToLower(o.res.Kind))
7068
}
7169

7270
err = (&scaffold.Scaffold{}).Execute(input.Options{},

0 commit comments

Comments
 (0)