From 8f04b14fd090aebaa3a9e51d56106ecb0cc525ea Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Mon, 20 May 2024 06:59:46 +0100 Subject: [PATCH] :warning: remove deprecated apis no longer used GetShortName and IsLegacyLayout --- pkg/plugin/helpers.go | 20 -------------------- pkg/plugin/helpers_test.go | 6 ------ pkg/plugins/golang/options.go | 16 +++------------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/pkg/plugin/helpers.go b/pkg/plugin/helpers.go index a957d4cb071..11e2fe45190 100644 --- a/pkg/plugin/helpers.go +++ b/pkg/plugin/helpers.go @@ -40,26 +40,6 @@ func SplitKey(key string) (string, string) { return keyParts[0], keyParts[1] } -// GetShortName returns plugin's short name (name before domain) if name -// is fully qualified (has a domain suffix), otherwise GetShortName returns name. -// Deprecated -func GetShortName(name string) string { - return strings.SplitN(name, ".", 2)[0] -} - -// Deprecated: it was added to ensure backwards compatibility and should -// be removed when we remove the go/v3 plugin -// IsLegacyLayout returns true when is possible to identify that the project -// was scaffolded with the previous layout -func IsLegacyLayout(config config.Config) bool { - for _, pluginKey := range config.GetPluginChain() { - if strings.Contains(pluginKey, "go.kubebuilder.io/v3") || strings.Contains(pluginKey, "go.kubebuilder.io/v2") { - return true - } - } - return false -} - // Validate ensures a Plugin is valid. func Validate(p Plugin) error { if err := validateName(p.Name()); err != nil { diff --git a/pkg/plugin/helpers_test.go b/pkg/plugin/helpers_test.go index f01caa25052..981265231ad 100644 --- a/pkg/plugin/helpers_test.go +++ b/pkg/plugin/helpers_test.go @@ -64,12 +64,6 @@ var _ = Describe("SplitKey", func() { }) }) -var _ = Describe("GetShortName", func() { - It("should extract base names from domains", func() { - Expect(GetShortName(name)).To(Equal(short)) - }) -}) - var _ = Describe("Validate", func() { It("should succeed for valid plugins", func() { plugin := mockPlugin{ diff --git a/pkg/plugins/golang/options.go b/pkg/plugins/golang/options.go index 548efdaf9c6..f3cc87cce47 100644 --- a/pkg/plugins/golang/options.go +++ b/pkg/plugins/golang/options.go @@ -21,7 +21,6 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/config" "sigs.k8s.io/kubebuilder/v3/pkg/model/resource" - "sigs.k8s.io/kubebuilder/v3/pkg/plugin" ) var ( @@ -76,11 +75,7 @@ func (opts Options) UpdateResource(res *resource.Resource, c config.Config) { if opts.DoAPI { //nolint:staticcheck - if plugin.IsLegacyLayout(c) { - res.Path = resource.APIPackagePathLegacy(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) - } else { - res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) - } + res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) res.API = &resource.API{ CRDVersion: "v1", @@ -94,14 +89,9 @@ func (opts Options) UpdateResource(res *resource.Resource, c config.Config) { } if opts.DoDefaulting || opts.DoValidation || opts.DoConversion { - // IsLegacyLayout is added to ensure backwards compatibility and should - // be removed when we remove the go/v3 plugin //nolint:staticcheck - if plugin.IsLegacyLayout(c) { - res.Path = resource.APIPackagePathLegacy(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) - } else { - res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) - } + res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup()) + res.Webhooks.WebhookVersion = "v1" if opts.DoDefaulting { res.Webhooks.Defaulting = true