@@ -55,6 +55,7 @@ import (
55
55
featuregatetesting "k8s.io/component-base/featuregate/testing"
56
56
"k8s.io/kube-openapi/pkg/validation/spec"
57
57
"k8s.io/kube-openapi/pkg/validation/strfmt"
58
+ "k8s.io/utils/ptr"
58
59
)
59
60
60
61
var stringSchema * apiextensionsv1.JSONSchemaProps = & apiextensionsv1.JSONSchemaProps {
@@ -1115,7 +1116,7 @@ func TestRatchetingFunctionality(t *testing.T) {
1115
1116
Properties : map [string ]apiextensionsv1.JSONSchemaProps {
1116
1117
"field" : {
1117
1118
Type : "array" ,
1118
- XListType : ptr ("map" ),
1119
+ XListType : ptr . To ("map" ),
1119
1120
XListMapKeys : []string {"name" , "port" },
1120
1121
Items : & apiextensionsv1.JSONSchemaPropsOrArray {
1121
1122
Schema : & apiextensionsv1.JSONSchemaProps {
@@ -1395,7 +1396,7 @@ func TestRatchetingFunctionality(t *testing.T) {
1395
1396
{
1396
1397
Rule : "!oldSelf.hasValue()" ,
1397
1398
Message : "oldSelf must be null" ,
1398
- OptionalOldSelf : ptr (true ),
1399
+ OptionalOldSelf : ptr . To (true ),
1399
1400
},
1400
1401
},
1401
1402
},
@@ -1445,7 +1446,7 @@ func TestRatchetingFunctionality(t *testing.T) {
1445
1446
Operations : []ratchetingTestOperation {
1446
1447
updateMyCRDV1Beta1Schema {& apiextensionsv1.JSONSchemaProps {
1447
1448
Type : "object" ,
1448
- XPreserveUnknownFields : ptr (true ),
1449
+ XPreserveUnknownFields : ptr . To (true ),
1449
1450
}},
1450
1451
applyPatchOperation {
1451
1452
"create instance with strings that do not start with k8s" ,
@@ -1457,7 +1458,7 @@ func TestRatchetingFunctionality(t *testing.T) {
1457
1458
},
1458
1459
updateMyCRDV1Beta1Schema {& apiextensionsv1.JSONSchemaProps {
1459
1460
Type : "object" ,
1460
- XPreserveUnknownFields : ptr (true ),
1461
+ XPreserveUnknownFields : ptr . To (true ),
1461
1462
Properties : map [string ]apiextensionsv1.JSONSchemaProps {
1462
1463
"myStringField" : {
1463
1464
Type : "string" ,
@@ -1759,10 +1760,6 @@ func TestRatchetingFunctionality(t *testing.T) {
1759
1760
runTests (t , cases )
1760
1761
}
1761
1762
1762
- func ptr [T any ](v T ) * T {
1763
- return & v
1764
- }
1765
-
1766
1763
type validator func (new , old * unstructured.Unstructured )
1767
1764
1768
1765
func newValidator (customResourceValidation * apiextensionsinternal.JSONSchemaProps , kind schema.GroupVersionKind , namespaceScoped bool ) (validator , error ) {
@@ -2031,7 +2028,7 @@ func TestRatchetingDropFields(t *testing.T) {
2031
2028
{
2032
2029
// Results in error if field wasn't dropped
2033
2030
Rule : "self == oldSelf" ,
2034
- OptionalOldSelf : ptr (true ),
2031
+ OptionalOldSelf : ptr . To (true ),
2035
2032
},
2036
2033
},
2037
2034
},
@@ -2064,7 +2061,7 @@ func TestRatchetingDropFields(t *testing.T) {
2064
2061
if err != nil {
2065
2062
return false , err
2066
2063
}
2067
- existing .Spec .Versions [0 ].Schema .OpenAPIV3Schema .Properties ["spec" ].Properties ["field" ].XValidations [0 ].OptionalOldSelf = ptr (true )
2064
+ existing .Spec .Versions [0 ].Schema .OpenAPIV3Schema .Properties ["spec" ].Properties ["field" ].XValidations [0 ].OptionalOldSelf = ptr . To (true )
2068
2065
updated , err = apiExtensionClient .ApiextensionsV1 ().CustomResourceDefinitions ().Update (context .TODO (), existing , metav1.UpdateOptions {})
2069
2066
if err != nil {
2070
2067
if apierrors .IsConflict (err ) {
0 commit comments