Skip to content

Commit

Permalink
⚠️ remove deprecated apis no longer used GetShortName and IsLegacyLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed May 20, 2024
1 parent af63282 commit 076fded
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
20 changes: 0 additions & 20 deletions pkg/plugin/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions pkg/plugin/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
16 changes: 3 additions & 13 deletions pkg/plugins/golang/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 076fded

Please sign in to comment.