diff --git a/pkg/cli/suite_test.go b/pkg/cli/suite_test.go index b25970be22c..1f669bd4d5f 100644 --- a/pkg/cli/suite_test.go +++ b/pkg/cli/suite_test.go @@ -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 diff --git a/pkg/plugin/bundle.go b/pkg/plugin/bundle.go index d1e0ba6d127..52c819a352c 100644 --- a/pkg/plugin/bundle.go +++ b/pkg/plugin/bundle.go @@ -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 diff --git a/pkg/plugin/filter.go b/pkg/plugin/filter.go index d678b081ecf..6ef3acc05c4 100644 --- a/pkg/plugin/filter.go +++ b/pkg/plugin/filter.go @@ -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 != "" diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index 0a22ac0cf08..93e5988b2f9 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -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 diff --git a/pkg/plugin/suite_test.go b/pkg/plugin/suite_test.go index 28c51857fb6..8b65d6b8216 100644 --- a/pkg/plugin/suite_test.go +++ b/pkg/plugin/suite_test.go @@ -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 } diff --git a/pkg/plugin/version.go b/pkg/plugin/version.go index c01d71be7c1..129860c22e8 100644 --- a/pkg/plugin/version.go +++ b/pkg/plugin/version.go @@ -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) @@ -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 } @@ -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 { @@ -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 diff --git a/pkg/plugins/common/kustomize/v2/plugin.go b/pkg/plugins/common/kustomize/v2/plugin.go index 56cc414a7fb..23e21c9fc4f 100644 --- a/pkg/plugins/common/kustomize/v2/plugin.go +++ b/pkg/plugins/common/kustomize/v2/plugin.go @@ -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 } diff --git a/pkg/plugins/external/plugin.go b/pkg/plugins/external/plugin.go index e5f8ec3f69a..7e230055c2b 100644 --- a/pkg/plugins/external/plugin.go +++ b/pkg/plugins/external/plugin.go @@ -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 } diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/plugin.go b/pkg/plugins/golang/deploy-image/v1alpha1/plugin.go index 4608e0dec79..830a9e15c7f 100644 --- a/pkg/plugins/golang/deploy-image/v1alpha1/plugin.go +++ b/pkg/plugins/golang/deploy-image/v1alpha1/plugin.go @@ -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 } diff --git a/pkg/plugins/golang/v4/plugin.go b/pkg/plugins/golang/v4/plugin.go index 19baeef40f0..d7eed3d7219 100644 --- a/pkg/plugins/golang/v4/plugin.go +++ b/pkg/plugins/golang/v4/plugin.go @@ -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 } diff --git a/pkg/plugins/optional/grafana/v1alpha/plugin.go b/pkg/plugins/optional/grafana/v1alpha/plugin.go index 39e77079cfd..753e83ec469 100644 --- a/pkg/plugins/optional/grafana/v1alpha/plugin.go +++ b/pkg/plugins/optional/grafana/v1alpha/plugin.go @@ -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 } diff --git a/pkg/plugins/optional/helm/v1alpha/plugin.go b/pkg/plugins/optional/helm/v1alpha/plugin.go index 41d97de288d..c76205ca365 100644 --- a/pkg/plugins/optional/helm/v1alpha/plugin.go +++ b/pkg/plugins/optional/helm/v1alpha/plugin.go @@ -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 }