Skip to content

Commit 490103b

Browse files
committed
🌱 (chore): convert plugin.Version receiver methods to use pointer receiver
This change updates methods on the `plugin.Version` type to use pointer receivers instead of value receivers.
1 parent d1fa042 commit 490103b

File tree

12 files changed

+16
-16
lines changed

12 files changed

+16
-16
lines changed

‎pkg/cli/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newMockPlugin(name, version string, projVers ...config.Version) plugin.Plug
5252
}
5353

5454
func (p mockPlugin) Name() string { return p.name }
55-
func (p mockPlugin) Version() plugin.Version { return p.version }
55+
func (p mockPlugin) Version() *plugin.Version { return &p.version }
5656
func (p mockPlugin) SupportedProjectVersions() []config.Version { return p.projectVersions }
5757

5858
type mockDeprecatedPlugin struct { //nolint:maligned

‎pkg/plugin/bundle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ func (b bundle) Name() string {
103103
}
104104

105105
// Version implements Plugin
106-
func (b bundle) Version() Version {
107-
return b.version
106+
func (b bundle) Version() *Version {
107+
return &b.version
108108
}
109109

110110
// SupportedProjectVersions implements Plugin

‎pkg/plugin/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"sigs.k8s.io/kubebuilder/v4/pkg/config"
2323
)
2424

25-
// FilterPluginsByKey returns the set of plugins that match the provided key (may be not-fully qualified)
25+
// FilterPluginsByKey returns the set of plugins that match the provided key (maybe not-fully qualified)
2626
func FilterPluginsByKey(plugins []Plugin, key string) ([]Plugin, error) {
2727
name, ver := SplitKey(key)
2828
hasVersion := ver != ""

‎pkg/plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Plugin interface {
2929
// Version returns the plugin's version.
3030
//
3131
// NOTE: this version is different from config version.
32-
Version() Version
32+
Version() *Version
3333
// SupportedProjectVersions lists all project configuration versions this plugin supports.
3434
// The returned slice cannot be empty.
3535
SupportedProjectVersions() []config.Version

‎pkg/plugin/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ type mockPlugin struct {
3737
}
3838

3939
func (p mockPlugin) Name() string { return p.name }
40-
func (p mockPlugin) Version() Version { return p.version }
40+
func (p mockPlugin) Version() *Version { return &p.version }
4141
func (p mockPlugin) SupportedProjectVersions() []config.Version { return p.supportedProjectVersions }

‎pkg/plugin/version.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (v *Version) Parse(version string) error {
6767
}
6868

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

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

8787
// Compare returns -1 if v < other, 0 if v == other, and 1 if v > other.
88-
func (v Version) Compare(other Version) int {
88+
func (v *Version) Compare(other Version) int {
8989
if v.Number > other.Number {
9090
return 1
9191
} else if v.Number < other.Number {
@@ -96,7 +96,7 @@ func (v Version) Compare(other Version) int {
9696
}
9797

9898
// IsStable returns true if v is stable.
99-
func (v Version) IsStable() bool {
99+
func (v *Version) IsStable() bool {
100100
// Plugin version 0 is not considered stable
101101
if v.Number == 0 {
102102
return false

‎pkg/plugins/common/kustomize/v2/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Plugin struct {
5151
func (Plugin) Name() string { return pluginName }
5252

5353
// Version returns the version of the plugin
54-
func (Plugin) Version() plugin.Version { return pluginVersion }
54+
func (Plugin) Version() *plugin.Version { return &pluginVersion }
5555

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

‎pkg/plugins/external/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Plugin struct {
3737
func (p Plugin) Name() string { return p.PName }
3838

3939
// Version returns the version of the plugin
40-
func (p Plugin) Version() plugin.Version { return p.PVersion }
40+
func (p Plugin) Version() *plugin.Version { return &p.PVersion }
4141

4242
// SupportedProjectVersions returns an array with all project versions supported by the plugin
4343
func (p Plugin) SupportedProjectVersions() []config.Version { return p.PSupportedProjectVersions }

‎pkg/plugins/golang/deploy-image/v1alpha1/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Plugin struct {
4343
func (Plugin) Name() string { return pluginName }
4444

4545
// Version returns the version of the plugin
46-
func (Plugin) Version() plugin.Version { return pluginVersion }
46+
func (Plugin) Version() *plugin.Version { return &pluginVersion }
4747

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

‎pkg/plugins/golang/v4/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type Plugin struct {
4545
func (Plugin) Name() string { return pluginName }
4646

4747
// Version returns the version of the plugin
48-
func (Plugin) Version() plugin.Version { return pluginVersion }
48+
func (Plugin) Version() *plugin.Version { return &pluginVersion }
4949

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

‎pkg/plugins/optional/grafana/v1alpha/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var _ plugin.Init = Plugin{}
4444
func (Plugin) Name() string { return pluginName }
4545

4646
// Version returns the version of the grafana plugin
47-
func (Plugin) Version() plugin.Version { return pluginVersion }
47+
func (Plugin) Version() *plugin.Version { return &pluginVersion }
4848

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

‎pkg/plugins/optional/helm/v1alpha/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type pluginConfig struct{}
4949
func (Plugin) Name() string { return pluginName }
5050

5151
// Version returns the version of the Helm plugin
52-
func (Plugin) Version() plugin.Version { return pluginVersion }
52+
func (Plugin) Version() *plugin.Version { return &pluginVersion }
5353

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

0 commit comments

Comments
 (0)