mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Simplify schema sentinel subresource logic
This commit is contained in:
parent
ba816967a0
commit
a2b12ba406
@ -232,17 +232,6 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
|
||||
sch.Properties = map[string]apiextensionsv1.JSONSchemaProps{}
|
||||
}
|
||||
|
||||
if ctx.StatusSubresource {
|
||||
sch = &apiextensionsv1.JSONSchemaProps{
|
||||
Type: "object",
|
||||
Properties: map[string]apiextensionsv1.JSONSchemaProps{
|
||||
"status": *sch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// sentinel must be in the root level of the schema.
|
||||
// Do not include this in the status schema.
|
||||
uuidString := string(uuid.NewUUID())
|
||||
sentinelName := "__ratcheting_sentinel_field__"
|
||||
sch.Properties[sentinelName] = apiextensionsv1.JSONSchemaProps{
|
||||
@ -252,6 +241,15 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
|
||||
}},
|
||||
}
|
||||
|
||||
if ctx.StatusSubresource {
|
||||
sch = &apiextensionsv1.JSONSchemaProps{
|
||||
Type: "object",
|
||||
Properties: map[string]apiextensionsv1.JSONSchemaProps{
|
||||
"status": *sch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range myCRD.Spec.Versions {
|
||||
if v.Name != myCRDV1Beta1.Version {
|
||||
continue
|
||||
@ -278,12 +276,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
|
||||
name: "sentinel-resource",
|
||||
patch: map[string]interface{}{
|
||||
sentinelName: fmt.Sprintf("invalid-%d", counter),
|
||||
}}.Do(&ratchetingTestContext{
|
||||
T: ctx.T,
|
||||
DynamicClient: ctx.DynamicClient,
|
||||
APIExtensionsClient: ctx.APIExtensionsClient,
|
||||
StatusSubresource: false, // Do not carry this over, sentinel check is in the root level.
|
||||
})
|
||||
}}.Do(ctx)
|
||||
|
||||
if err == nil {
|
||||
return false, errors.New("expected error when creating sentinel resource")
|
||||
|
Loading…
Reference in New Issue
Block a user