mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +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{}
|
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())
|
uuidString := string(uuid.NewUUID())
|
||||||
sentinelName := "__ratcheting_sentinel_field__"
|
sentinelName := "__ratcheting_sentinel_field__"
|
||||||
sch.Properties[sentinelName] = apiextensionsv1.JSONSchemaProps{
|
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 {
|
for _, v := range myCRD.Spec.Versions {
|
||||||
if v.Name != myCRDV1Beta1.Version {
|
if v.Name != myCRDV1Beta1.Version {
|
||||||
continue
|
continue
|
||||||
@ -278,12 +276,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
|
|||||||
name: "sentinel-resource",
|
name: "sentinel-resource",
|
||||||
patch: map[string]interface{}{
|
patch: map[string]interface{}{
|
||||||
sentinelName: fmt.Sprintf("invalid-%d", counter),
|
sentinelName: fmt.Sprintf("invalid-%d", counter),
|
||||||
}}.Do(&ratchetingTestContext{
|
}}.Do(ctx)
|
||||||
T: ctx.T,
|
|
||||||
DynamicClient: ctx.DynamicClient,
|
|
||||||
APIExtensionsClient: ctx.APIExtensionsClient,
|
|
||||||
StatusSubresource: false, // Do not carry this over, sentinel check is in the root level.
|
|
||||||
})
|
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return false, errors.New("expected error when creating sentinel resource")
|
return false, errors.New("expected error when creating sentinel resource")
|
||||||
|
Loading…
Reference in New Issue
Block a user