Skip to content

Commit 5fa1586

Browse files
committed
Adjust unit tests to k8s.io/* v1.32.0
1 parent dada367 commit 5fa1586

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

internal/controllers/clusterclass/clusterclass_controller_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ import (
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
"k8s.io/apimachinery/pkg/types"
3232
"k8s.io/apimachinery/pkg/util/version"
33-
utilversion "k8s.io/apiserver/pkg/util/version"
33+
"k8s.io/component-base/featuregate"
3434
utilfeature "k8s.io/component-base/featuregate/testing"
35+
utilversion "k8s.io/component-base/version"
3536
"k8s.io/klog/v2"
3637
"k8s.io/utils/ptr"
3738
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -1162,13 +1163,13 @@ func TestReconciler_reconcileVariables(t *testing.T) {
11621163

11631164
// Pin the compatibility version used in variable CEL validation to 1.29, so we don't have to continuously refactor
11641165
// the unit tests that verify that compatibility is handled correctly.
1165-
effectiveVer := utilversion.DefaultComponentGlobalsRegistry.EffectiveVersionFor(utilversion.DefaultKubeComponent)
1166+
effectiveVer := featuregate.DefaultComponentGlobalsRegistry.EffectiveVersionFor(featuregate.DefaultKubeComponent)
11661167
if effectiveVer != nil {
11671168
g.Expect(effectiveVer.MinCompatibilityVersion()).To(Equal(version.MustParse("v1.29")))
11681169
} else {
11691170
v := utilversion.DefaultKubeEffectiveVersion()
11701171
v.SetMinCompatibilityVersion(version.MustParse("v1.29"))
1171-
g.Expect(utilversion.DefaultComponentGlobalsRegistry.Register(utilversion.DefaultKubeComponent, v, nil)).To(Succeed())
1172+
g.Expect(featuregate.DefaultComponentGlobalsRegistry.Register(featuregate.DefaultKubeComponent, v, nil)).To(Succeed())
11721173
}
11731174

11741175
s := &scope{

internal/topology/variables/clusterclass_variable_validation_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2626
"k8s.io/apimachinery/pkg/util/validation/field"
2727
"k8s.io/apimachinery/pkg/util/version"
28-
utilversion "k8s.io/apiserver/pkg/util/version"
28+
"k8s.io/component-base/featuregate"
29+
utilversion "k8s.io/component-base/version"
2930
"k8s.io/utils/ptr"
3031

3132
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -346,13 +347,13 @@ func Test_ValidateClusterClassVariables(t *testing.T) {
346347

347348
// Pin the compatibility version used in variable CEL validation to 1.29, so we don't have to continuously refactor
348349
// the unit tests that verify that compatibility is handled correctly.
349-
effectiveVer := utilversion.DefaultComponentGlobalsRegistry.EffectiveVersionFor(utilversion.DefaultKubeComponent)
350+
effectiveVer := featuregate.DefaultComponentGlobalsRegistry.EffectiveVersionFor(featuregate.DefaultKubeComponent)
350351
if effectiveVer != nil {
351352
g.Expect(effectiveVer.MinCompatibilityVersion()).To(Equal(version.MustParse("v1.29")))
352353
} else {
353354
v := utilversion.DefaultKubeEffectiveVersion()
354355
v.SetMinCompatibilityVersion(version.MustParse("v1.29"))
355-
g.Expect(utilversion.DefaultComponentGlobalsRegistry.Register(utilversion.DefaultKubeComponent, v, nil)).To(Succeed())
356+
g.Expect(featuregate.DefaultComponentGlobalsRegistry.Register(featuregate.DefaultKubeComponent, v, nil)).To(Succeed())
356357
}
357358

358359
gotErrs := ValidateClusterClassVariables(ctx,
@@ -1275,7 +1276,7 @@ func Test_ValidateClusterClassVariable(t *testing.T) {
12751276
},
12761277
},
12771278
wantErrs: []validationMatch{
1278-
toolong("Too long: may not be longer than 6",
1279+
toolong("Too long: may not be more than 6 bytes",
12791280
"spec.variables[var].schema.openAPIV3Schema.default"),
12801281
},
12811282
},
@@ -1295,7 +1296,7 @@ func Test_ValidateClusterClassVariable(t *testing.T) {
12951296
},
12961297
},
12971298
wantErrs: []validationMatch{
1298-
toolong("Too long: may not be longer than 6",
1299+
toolong("Too long: may not be more than 6 bytes",
12991300
"spec.variables[var].schema.openAPIV3Schema.items.default"),
13001301
},
13011302
},
@@ -1495,7 +1496,7 @@ func Test_ValidateClusterClassVariable(t *testing.T) {
14951496
},
14961497
},
14971498
wantErrs: []validationMatch{
1498-
toolong("Too long: may not be longer than 6",
1499+
toolong("Too long: may not be more than 6 bytes",
14991500
"spec.variables[var].schema.openAPIV3Schema.example"),
15001501
},
15011502
},
@@ -1636,7 +1637,7 @@ func Test_ValidateClusterClassVariable(t *testing.T) {
16361637
},
16371638
},
16381639
wantErrs: []validationMatch{
1639-
toolong("may not be longer than 6",
1640+
toolong("may not be more than 6 bytes",
16401641
"spec.variables[var].schema.openAPIV3Schema.enum[0]"),
16411642
},
16421643
},

internal/webhooks/clusterclass_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import (
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
2828
"k8s.io/apimachinery/pkg/util/version"
29-
utilversion "k8s.io/apiserver/pkg/util/version"
29+
"k8s.io/component-base/featuregate"
3030
utilfeature "k8s.io/component-base/featuregate/testing"
31+
utilversion "k8s.io/component-base/version"
3132
"k8s.io/utils/ptr"
3233
ctrl "sigs.k8s.io/controller-runtime"
3334
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -1870,13 +1871,13 @@ func TestClusterClassValidation(t *testing.T) {
18701871

18711872
// Pin the compatibility version used in variable CEL validation to 1.29, so we don't have to continuously refactor
18721873
// the unit tests that verify that compatibility is handled correctly.
1873-
effectiveVer := utilversion.DefaultComponentGlobalsRegistry.EffectiveVersionFor(utilversion.DefaultKubeComponent)
1874+
effectiveVer := featuregate.DefaultComponentGlobalsRegistry.EffectiveVersionFor(featuregate.DefaultKubeComponent)
18741875
if effectiveVer != nil {
18751876
g.Expect(effectiveVer.MinCompatibilityVersion()).To(Equal(version.MustParse("v1.29")))
18761877
} else {
18771878
v := utilversion.DefaultKubeEffectiveVersion()
18781879
v.SetMinCompatibilityVersion(version.MustParse("v1.29"))
1879-
g.Expect(utilversion.DefaultComponentGlobalsRegistry.Register(utilversion.DefaultKubeComponent, v, nil)).To(Succeed())
1880+
g.Expect(featuregate.DefaultComponentGlobalsRegistry.Register(featuregate.DefaultKubeComponent, v, nil)).To(Succeed())
18801881
}
18811882

18821883
// Create the webhook and add the fakeClient as its client.

0 commit comments

Comments
 (0)