remove confusing flexibility for metadata interpretation

Kubernetes-commit: 0710f72c65ad23e7a3726b345898ef4aaaac26fa
This commit is contained in:
David Eads 2018-04-23 10:23:01 -04:00 committed by Kubernetes Publisher
parent 3631461fc7
commit c726896549
2 changed files with 11 additions and 10 deletions

View File

@ -26,15 +26,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )
// VersionInterfaces provides an object converter and metadata
// accessor appropriate for use with unstructured objects.
func VersionInterfaces(schema.GroupVersion) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
MetadataAccessor: meta.NewAccessor(),
}, nil
}
// NewDiscoveryRESTMapper returns a RESTMapper based on discovery information. // NewDiscoveryRESTMapper returns a RESTMapper based on discovery information.
func NewDiscoveryRESTMapper(resources []*metav1.APIResourceList, versionFunc meta.VersionInterfacesFunc) (*meta.DefaultRESTMapper, error) { func NewDiscoveryRESTMapper(resources []*metav1.APIResourceList, versionFunc meta.VersionInterfacesFunc) (*meta.DefaultRESTMapper, error) {
rm := meta.NewDefaultRESTMapper(nil, versionFunc) rm := meta.NewDefaultRESTMapper(nil, versionFunc)

View File

@ -19,7 +19,9 @@ package dynamic
import ( import (
"testing" "testing"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )
@ -43,7 +45,7 @@ func TestDiscoveryRESTMapper(t *testing.T) {
Kind: "test_kind", Kind: "test_kind",
} }
mapper, err := NewDiscoveryRESTMapper(resources, VersionInterfaces) mapper, err := NewDiscoveryRESTMapper(resources, versionInterfaces)
if err != nil { if err != nil {
t.Fatalf("unexpected error creating mapper: %s", err) t.Fatalf("unexpected error creating mapper: %s", err)
} }
@ -77,3 +79,11 @@ func TestDiscoveryRESTMapper(t *testing.T) {
} }
} }
} }
// VersionInterfaces provides an object converter and metadata
// accessor appropriate for use with unstructured objects.
func versionInterfaces(schema.GroupVersion) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
}, nil
}