Skip to content

Commit 28bf934

Browse files
committed
Normalize canonicalMaxClusterVersion (e.g. v4.15.0-0 instead of v4.15.0)
Signed-off-by: Jenny Zhu <[email protected]>
1 parent 73db74f commit 28bf934

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

pkg/controllers/uiplugin/compatibility_matrix.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package uiplugin
33
import (
44
"context"
55
"fmt"
6+
// "log"
67
"strings"
78

89
"golang.org/x/mod/semver"
@@ -160,7 +161,7 @@ func lookupImageAndFeatures(pluginType uiv1alpha1.UIPluginType, clusterVersion s
160161

161162
func compareClusterVersion(entry CompatibilityEntry, clusterVersion string, pluginType uiv1alpha1.UIPluginType) (CompatibilityEntry, error) {
162163
canonicalMinClusterVersion := fmt.Sprintf("%s-0", semver.Canonical(entry.MinClusterVersion))
163-
canonicalMaxClusterVersion := semver.Canonical(entry.MaxClusterVersion)
164+
canonicalMaxClusterVersion := fmt.Sprintf("%s-0", semver.Canonical(entry.MaxClusterVersion))
164165

165166
if entry.MaxClusterVersion == "" && semver.Compare(clusterVersion, canonicalMinClusterVersion) >= 0 {
166167
return entry, nil

pkg/controllers/uiplugin/compatibility_matrix_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@ func TestLookupImageAndFeatures(t *testing.T) {
122122
"dev-alerts",
123123
},
124124
},
125+
{
126+
pluginType: uiv1alpha1.TypeLogging,
127+
clusterVersion: "v4.15.0-0.nightly-2024-06-06-064349",
128+
expectedKey: "ui-logging",
129+
expectedErr: nil,
130+
expectedFeatures: []string{
131+
"dev-console",
132+
"alerts",
133+
"dev-alerts",
134+
},
135+
},
136+
{
137+
pluginType: uiv1alpha1.TypeLogging,
138+
clusterVersion: "4.15.46",
139+
expectedKey: "ui-logging",
140+
expectedErr: nil,
141+
expectedFeatures: []string{
142+
"dev-console",
143+
"alerts",
144+
"dev-alerts",
145+
},
146+
},
125147
{
126148
pluginType: uiv1alpha1.TypeLogging,
127149
clusterVersion: "v4.16.9",
@@ -183,6 +205,18 @@ func TestLookupImageAndFeatures(t *testing.T) {
183205
expectedKey: "ui-distributed-tracing",
184206
expectedErr: nil,
185207
},
208+
{
209+
pluginType: uiv1alpha1.TypeDistributedTracing,
210+
clusterVersion: "v4.15.0-0.nightly-2024-06-06-064349",
211+
expectedKey: "ui-distributed-tracing",
212+
expectedErr: nil,
213+
},
214+
{
215+
pluginType: uiv1alpha1.TypeDistributedTracing,
216+
clusterVersion: "v4.15.46",
217+
expectedKey: "ui-distributed-tracing",
218+
expectedErr: nil,
219+
},
186220
{
187221
pluginType: uiv1alpha1.TypeDistributedTracing,
188222
clusterVersion: "4.24.0-0.nightly-2024-03-11-200348",
@@ -231,6 +265,8 @@ func TestLookupImageAndFeatures(t *testing.T) {
231265
t.Run(fmt.Sprintf("%s/%s", tc.pluginType, tc.clusterVersion), func(t *testing.T) {
232266
info, err := lookupImageAndFeatures(tc.pluginType, tc.clusterVersion)
233267

268+
t.Log(info)
269+
234270
if tc.expectedErr != nil {
235271
assert.Error(t, err, tc.expectedErr.Error())
236272
return

0 commit comments

Comments
 (0)