Skip to content

🌱 (chore): convert plugin.Version receiver methods to use pointer receiver #4733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cli/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newMockPlugin(name, version string, projVers ...config.Version) plugin.Plug
}

func (p mockPlugin) Name() string { return p.name }
func (p mockPlugin) Version() plugin.Version { return p.version }
func (p mockPlugin) Version() *plugin.Version { return &p.version }
func (p mockPlugin) SupportedProjectVersions() []config.Version { return p.projectVersions }

type mockDeprecatedPlugin struct { //nolint:maligned
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func (b bundle) Name() string {
}

// Version implements Plugin
func (b bundle) Version() Version {
return b.version
func (b bundle) Version() *Version {
return &b.version
}

// SupportedProjectVersions implements Plugin
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"sigs.k8s.io/kubebuilder/v4/pkg/config"
)

// FilterPluginsByKey returns the set of plugins that match the provided key (may be not-fully qualified)
// FilterPluginsByKey returns the set of plugins that match the provided key (maybe not-fully qualified)
func FilterPluginsByKey(plugins []Plugin, key string) ([]Plugin, error) {
name, ver := SplitKey(key)
hasVersion := ver != ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Plugin interface {
// Version returns the plugin's version.
//
// NOTE: this version is different from config version.
Version() Version
Version() *Version
// SupportedProjectVersions lists all project configuration versions this plugin supports.
// The returned slice cannot be empty.
SupportedProjectVersions() []config.Version
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ type mockPlugin struct {
}

func (p mockPlugin) Name() string { return p.name }
func (p mockPlugin) Version() Version { return p.version }
func (p mockPlugin) Version() *Version { return &p.version }
func (p mockPlugin) SupportedProjectVersions() []config.Version { return p.supportedProjectVersions }
8 changes: 4 additions & 4 deletions pkg/plugin/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (v *Version) Parse(version string) error {
}

// String returns the string representation of v.
func (v Version) String() string {
func (v *Version) String() string {
stageStr := v.Stage.String()
if len(stageStr) == 0 {
return fmt.Sprintf("v%d", v.Number)
Expand All @@ -76,7 +76,7 @@ func (v Version) String() string {
}

// Validate ensures that the version number is positive and the stage is one of the valid stages.
func (v Version) Validate() error {
func (v *Version) Validate() error {
if v.Number < 0 {
return errNegative
}
Expand All @@ -85,7 +85,7 @@ func (v Version) Validate() error {
}

// Compare returns -1 if v < other, 0 if v == other, and 1 if v > other.
func (v Version) Compare(other Version) int {
func (v *Version) Compare(other Version) int {
if v.Number > other.Number {
return 1
} else if v.Number < other.Number {
Expand All @@ -96,7 +96,7 @@ func (v Version) Compare(other Version) int {
}

// IsStable returns true if v is stable.
func (v Version) IsStable() bool {
func (v *Version) IsStable() bool {
// Plugin version 0 is not considered stable
if v.Number == 0 {
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/common/kustomize/v2/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Plugin struct {
func (Plugin) Name() string { return pluginName }

// Version returns the version of the plugin
func (Plugin) Version() plugin.Version { return pluginVersion }
func (Plugin) Version() *plugin.Version { return &pluginVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/external/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Plugin struct {
func (p Plugin) Name() string { return p.PName }

// Version returns the version of the plugin
func (p Plugin) Version() plugin.Version { return p.PVersion }
func (p Plugin) Version() *plugin.Version { return &p.PVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (p Plugin) SupportedProjectVersions() []config.Version { return p.PSupportedProjectVersions }
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/golang/deploy-image/v1alpha1/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Plugin struct {
func (Plugin) Name() string { return pluginName }

// Version returns the version of the plugin
func (Plugin) Version() plugin.Version { return pluginVersion }
func (Plugin) Version() *plugin.Version { return &pluginVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/golang/v4/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Plugin struct {
func (Plugin) Name() string { return pluginName }

// Version returns the version of the plugin
func (Plugin) Version() plugin.Version { return pluginVersion }
func (Plugin) Version() *plugin.Version { return &pluginVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/optional/grafana/v1alpha/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ plugin.Init = Plugin{}
func (Plugin) Name() string { return pluginName }

// Version returns the version of the grafana plugin
func (Plugin) Version() plugin.Version { return pluginVersion }
func (Plugin) Version() *plugin.Version { return &pluginVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/optional/helm/v1alpha/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type pluginConfig struct{}
func (Plugin) Name() string { return pluginName }

// Version returns the version of the Helm plugin
func (Plugin) Version() plugin.Version { return pluginVersion }
func (Plugin) Version() *plugin.Version { return &pluginVersion }

// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
Expand Down
Loading