Skip to content

Commit a2b12ba

Browse files
committed
Simplify schema sentinel subresource logic
1 parent ba81696 commit a2b12ba

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

staging/src/k8s.io/apiextensions-apiserver/test/integration/ratcheting_test.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,6 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
232232
sch.Properties = map[string]apiextensionsv1.JSONSchemaProps{}
233233
}
234234

235-
if ctx.StatusSubresource {
236-
sch = &apiextensionsv1.JSONSchemaProps{
237-
Type: "object",
238-
Properties: map[string]apiextensionsv1.JSONSchemaProps{
239-
"status": *sch,
240-
},
241-
}
242-
}
243-
244-
// sentinel must be in the root level of the schema.
245-
// Do not include this in the status schema.
246235
uuidString := string(uuid.NewUUID())
247236
sentinelName := "__ratcheting_sentinel_field__"
248237
sch.Properties[sentinelName] = apiextensionsv1.JSONSchemaProps{
@@ -252,6 +241,15 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
252241
}},
253242
}
254243

244+
if ctx.StatusSubresource {
245+
sch = &apiextensionsv1.JSONSchemaProps{
246+
Type: "object",
247+
Properties: map[string]apiextensionsv1.JSONSchemaProps{
248+
"status": *sch,
249+
},
250+
}
251+
}
252+
255253
for _, v := range myCRD.Spec.Versions {
256254
if v.Name != myCRDV1Beta1.Version {
257255
continue
@@ -278,12 +276,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
278276
name: "sentinel-resource",
279277
patch: map[string]interface{}{
280278
sentinelName: fmt.Sprintf("invalid-%d", counter),
281-
}}.Do(&ratchetingTestContext{
282-
T: ctx.T,
283-
DynamicClient: ctx.DynamicClient,
284-
APIExtensionsClient: ctx.APIExtensionsClient,
285-
StatusSubresource: false, // Do not carry this over, sentinel check is in the root level.
286-
})
279+
}}.Do(ctx)
287280

288281
if err == nil {
289282
return false, errors.New("expected error when creating sentinel resource")

0 commit comments

Comments
 (0)