storage: move the APIObjectVersioner definition to storage

The means by which we extract and parse the version of an API object is
not specific to etcd3. In order to allow for a generic suite of tests
against any storage.Interface imlpementation, we need this logic to live
outside of the etcd3 package, or import cycles will exist.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
Steve Kuznetsov
2022-05-11 07:44:21 -07:00
parent c50579afb1
commit 3939f3003e
13 changed files with 31 additions and 33 deletions

View File

@@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/storage/etcd3"
"k8s.io/apiserver/pkg/storage"
"k8s.io/client-go/dynamic"
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
)
@@ -119,11 +119,14 @@ func TestCrossGroupStorage(t *testing.T) {
}
}
versioner := etcd3.APIObjectVersioner{}
versioner := storage.APIObjectVersioner{}
for _, resource := range resources {
// clear out the things cleared in etcd
versioned := versionedData[resource.Mapping.Resource]
versioner.PrepareObjectForStorage(versioned)
if err := versioner.PrepareObjectForStorage(versioned); err != nil {
t.Error(err)
continue
}
versionedJSON, err := versioned.MarshalJSON()
if err != nil {
t.Error(err)