do not round trip embedded v2

This commit is contained in:
Jiahui Feng 2022-03-24 14:44:15 -07:00 committed by Indeed
parent 32ca378825
commit 679dc8322c

View File

@ -22,6 +22,7 @@ import (
"testing"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kube-openapi/pkg/common"
"k8s.io/kube-openapi/pkg/handler"
"k8s.io/kube-openapi/pkg/validation/spec"
)
@ -44,6 +45,12 @@ func TestOpenAPIRoundtrip(t *testing.T) {
return
}
// Remove the embedded v2 schema if it presents.
// The v2 schema either become the schema (when serving v2) or get pruned (v3)
// and it is never round-tripped.
delete(roundTripped.Extensions, common.ExtensionV2Schema)
delete(value.Schema.Extensions, common.ExtensionV2Schema)
if !reflect.DeepEqual(value.Schema, roundTripped) {
t.Errorf("unexpected diff (a=expected,b=roundtripped):\n%s", diff.ObjectReflectDiff(value.Schema, roundTripped))
return