@@ -974,8 +974,8 @@ func TestReconciler_reconcileVariables(t *testing.T) {
974
974
OpenAPIV3Schema : clusterv1.JSONSchemaProps {
975
975
Type : "string" ,
976
976
XValidations : []clusterv1.ValidationRule {{
977
- // Note: IP will be only available if the compatibility version is 1.30
978
- Rule : "ip(self).family() == 6 " ,
977
+ // Note: format will be only available if the compatibility version is 1.31
978
+ Rule : "format.date().validate( \" 2021-01-01 \" ) " ,
979
979
}},
980
980
},
981
981
},
@@ -984,13 +984,16 @@ func TestReconciler_reconcileVariables(t *testing.T) {
984
984
},
985
985
wantErrMessage : "failed to discover variables for ClusterClass class1: " +
986
986
"patch1.variables[someIP].schema.openAPIV3Schema.x-kubernetes-validations[0].rule: Invalid value: " +
987
- "apiextensions.ValidationRule{Rule:\" ip(self).family() == 6\" , Message:\" \" , MessageExpression:\" \" , Reason:(*apiextensions.FieldValueErrorReason)(nil), FieldPath:\" \" , OptionalOldSelf:(*bool)(nil)}: compilation failed: " +
988
- "ERROR: <input>:1:3: undeclared reference to 'ip' (in container '')\n " +
989
- " | ip(self).family() == 6\n " +
990
- " | ..^\n " +
991
- "ERROR: <input>:1:16: undeclared reference to 'family' (in container '')\n " +
992
- " | ip(self).family() == 6\n " +
993
- " | ...............^" ,
987
+ "apiextensions.ValidationRule{Rule:\" format.date().validate(\\ \" 2021-01-01\\ \" )\" , Message:\" \" , MessageExpression:\" \" , " +
988
+ "Reason:(*apiextensions.FieldValueErrorReason)(nil), FieldPath:\" \" , OptionalOldSelf:(*bool)(nil)}: " +
989
+ "compilation failed: ERROR: <input>:1:1: undeclared reference to 'format' (in container '')\n " +
990
+ "| format.date().validate(\" 2021-01-01\" )\n " +
991
+ "| ^\n ERROR: <input>:1:12: undeclared reference to 'date' (in container '')\n " +
992
+ "| format.date().validate(\" 2021-01-01\" )\n " +
993
+ "| ...........^\n " +
994
+ "ERROR: <input>:1:23: undeclared reference to 'validate' (in container '')\n " +
995
+ "| format.date().validate(\" 2021-01-01\" )\n " +
996
+ "| ......................^" ,
994
997
},
995
998
}
996
999
for _ , tt := range tests {
@@ -1010,6 +1013,7 @@ func TestReconciler_reconcileVariables(t *testing.T) {
1010
1013
1011
1014
err := r .reconcileVariables (ctx , tt .clusterClass )
1012
1015
if tt .wantErrMessage != "" {
1016
+ g .Expect (err ).To (HaveOccurred ())
1013
1017
g .Expect (err .Error ()).To (Equal (tt .wantErrMessage ))
1014
1018
return
1015
1019
}
0 commit comments