@@ -220,23 +220,12 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
220
220
}
221
221
222
222
uuidString := string (uuid .NewUUID ())
223
- // UUID string is just hex separated by dashes, which is safe to
224
- // throw into regex like this
225
- pattern := "^" + uuidString + "$"
226
223
sentinelName := "__ratcheting_sentinel_field__"
227
224
sch .Properties [sentinelName ] = apiextensionsv1.JSONSchemaProps {
228
- Type : "string" ,
229
- Pattern : pattern ,
230
-
231
- // Put MaxLength condition inside AllOf since the string_validator
232
- // in kube-openapi short circuits upon seeing MaxLength, and we
233
- // want both pattern and MaxLength errors
234
- AllOf : []apiextensionsv1.JSONSchemaProps {
235
- {
236
- MinLength : ptr ((int64 (1 ))), // 1 MinLength to prevent empty value from ever being admitted
237
- MaxLength : ptr ((int64 (0 ))), // 0 MaxLength to prevent non-empty value from ever being admitted
238
- },
239
- },
225
+ Type : "string" ,
226
+ Enum : []apiextensionsv1.JSON {{
227
+ Raw : []byte (`"` + uuidString + `"` ),
228
+ }},
240
229
}
241
230
242
231
for _ , v := range myCRD .Spec .Versions {
@@ -254,7 +243,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
254
243
}
255
244
256
245
// Keep trying to create an invalid instance of the CRD until we
257
- // get an error containing the ResourceVersion we are looking for
246
+ // get an error containing the message we are looking for
258
247
//
259
248
counter := 0
260
249
return wait .PollUntilContextCancel (context .TODO (), 100 * time .Millisecond , true , func (_ context.Context ) (done bool , err error ) {
@@ -263,8 +252,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
263
252
gvr : myCRDV1Beta1 ,
264
253
name : "sentinel-resource" ,
265
254
patch : map [string ]interface {}{
266
- // Just keep using different values
267
- sentinelName : fmt .Sprintf ("invalid %v %v" , uuidString , counter ),
255
+ sentinelName : fmt .Sprintf ("invalid-%d" , counter ),
268
256
}}.Do (ctx )
269
257
270
258
if err == nil {
0 commit comments