mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Remove runtime.Typer, reduce to ObjectKinds(1) (3)
Remove the unnecessary variants, which avoids allocations in several core paths.
This commit is contained in:
		@@ -57,11 +57,11 @@ func GetReference(obj runtime.Object) (*ObjectReference, error) {
 | 
				
			|||||||
	kind := gvk.Kind
 | 
						kind := gvk.Kind
 | 
				
			||||||
	if len(kind) == 0 {
 | 
						if len(kind) == 0 {
 | 
				
			||||||
		// TODO: this is wrong
 | 
							// TODO: this is wrong
 | 
				
			||||||
		gvk, err := Scheme.ObjectKind(obj)
 | 
							gvks, _, err := Scheme.ObjectKinds(obj)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		kind = gvk.Kind
 | 
							kind = gvks[0].Kind
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// if the object referenced is actually persisted, we can also get version from meta
 | 
						// if the object referenced is actually persisted, we can also get version from meta
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ func TestGetReference(t *testing.T) {
 | 
				
			|||||||
	// when vendoring kube, if you don't force the set of registered versions (like this hack/test-go.sh does)
 | 
						// when vendoring kube, if you don't force the set of registered versions (like this hack/test-go.sh does)
 | 
				
			||||||
	// then you run into trouble because the types aren't registered in the scheme by anything.  This does the
 | 
						// then you run into trouble because the types aren't registered in the scheme by anything.  This does the
 | 
				
			||||||
	// register manually to allow unit test execution
 | 
						// register manually to allow unit test execution
 | 
				
			||||||
	if _, err := Scheme.ObjectKind(&Pod{}); err != nil {
 | 
						if _, _, err := Scheme.ObjectKinds(&Pod{}); err != nil {
 | 
				
			||||||
		AddToScheme(Scheme)
 | 
							AddToScheme(Scheme)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -112,11 +112,11 @@ func objectMetaAndKind(typer runtime.ObjectTyper, obj runtime.Object) (*api.Obje
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
 | 
							return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	kind, err := typer.ObjectKind(obj)
 | 
						kinds, _, err := typer.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
 | 
							return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return objectMeta, kind, nil
 | 
						return objectMeta, kinds[0], nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NamespaceScopedStrategy has a method to tell if the object must be in a namespace.
 | 
					// NamespaceScopedStrategy has a method to tell if the object must be in a namespace.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	codecsToTest = append(codecsToTest, func(version unversioned.GroupVersion, item runtime.Object) (runtime.Codec, error) {
 | 
						codecsToTest = append(codecsToTest, func(version unversioned.GroupVersion, item runtime.Object) (runtime.Codec, error) {
 | 
				
			||||||
		s := protobuf.NewSerializer(api.Scheme, runtime.ObjectTyperToTyper(api.Scheme), "application/arbitrary.content.type")
 | 
							s := protobuf.NewSerializer(api.Scheme, api.Scheme, "application/arbitrary.content.type")
 | 
				
			||||||
		return api.Codecs.CodecForVersions(s, s, testapi.ExternalGroupVersions(), nil), nil
 | 
							return api.Codecs.CodecForVersions(s, s, testapi.ExternalGroupVersions(), nil), nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -138,7 +138,7 @@ func BenchmarkEncodeProtobufGeneratedMarshal(b *testing.B) {
 | 
				
			|||||||
func BenchmarkDecodeCodecToInternalProtobuf(b *testing.B) {
 | 
					func BenchmarkDecodeCodecToInternalProtobuf(b *testing.B) {
 | 
				
			||||||
	items := benchmarkItems()
 | 
						items := benchmarkItems()
 | 
				
			||||||
	width := len(items)
 | 
						width := len(items)
 | 
				
			||||||
	s := protobuf.NewSerializer(api.Scheme, runtime.ObjectTyperToTyper(api.Scheme), "application/arbitrary.content.type")
 | 
						s := protobuf.NewSerializer(api.Scheme, api.Scheme, "application/arbitrary.content.type")
 | 
				
			||||||
	encoder := api.Codecs.EncoderForVersion(s, v1.SchemeGroupVersion)
 | 
						encoder := api.Codecs.EncoderForVersion(s, v1.SchemeGroupVersion)
 | 
				
			||||||
	var encoded [][]byte
 | 
						var encoded [][]byte
 | 
				
			||||||
	for i := range items {
 | 
						for i := range items {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -354,10 +354,11 @@ func ExternalGroupVersions() []unversioned.GroupVersion {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Get codec based on runtime.Object
 | 
					// Get codec based on runtime.Object
 | 
				
			||||||
func GetCodecForObject(obj runtime.Object) (runtime.Codec, error) {
 | 
					func GetCodecForObject(obj runtime.Object) (runtime.Codec, error) {
 | 
				
			||||||
	kind, err := api.Scheme.ObjectKind(obj)
 | 
						kinds, _, err := api.Scheme.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("unexpected encoding error: %v", err)
 | 
							return nil, fmt.Errorf("unexpected encoding error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						kind := kinds[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, group := range Groups {
 | 
						for _, group := range Groups {
 | 
				
			||||||
		if group.GroupVersion().Group != kind.Group {
 | 
							if group.GroupVersion().Group != kind.Group {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,7 +118,7 @@ func (a *APIInstaller) getResourceKind(path string, storage rest.Storage) (unver
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	object := storage.New()
 | 
						object := storage.New()
 | 
				
			||||||
	fqKinds, err := a.group.Typer.ObjectKinds(object)
 | 
						fqKinds, _, err := a.group.Typer.ObjectKinds(object)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return unversioned.GroupVersionKind{}, err
 | 
							return unversioned.GroupVersionKind{}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -233,8 +233,11 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
 | 
				
			|||||||
	var versionedList interface{}
 | 
						var versionedList interface{}
 | 
				
			||||||
	if isLister {
 | 
						if isLister {
 | 
				
			||||||
		list := lister.NewList()
 | 
							list := lister.NewList()
 | 
				
			||||||
		listGVK, err := a.group.Typer.ObjectKind(list)
 | 
							listGVKs, _, err := a.group.Typer.ObjectKinds(list)
 | 
				
			||||||
		versionedListPtr, err := a.group.Creater.New(a.group.GroupVersion.WithKind(listGVK.Kind))
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							versionedListPtr, err := a.group.Creater.New(a.group.GroupVersion.WithKind(listGVKs[0].Kind))
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -272,10 +275,11 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
 | 
				
			|||||||
	)
 | 
						)
 | 
				
			||||||
	if isGetterWithOptions {
 | 
						if isGetterWithOptions {
 | 
				
			||||||
		getOptions, getSubpath, _ = getterWithOptions.NewGetOptions()
 | 
							getOptions, getSubpath, _ = getterWithOptions.NewGetOptions()
 | 
				
			||||||
		getOptionsInternalKind, err = a.group.Typer.ObjectKind(getOptions)
 | 
							getOptionsInternalKinds, _, err := a.group.Typer.ObjectKinds(getOptions)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							getOptionsInternalKind = getOptionsInternalKinds[0]
 | 
				
			||||||
		versionedGetOptions, err = a.group.Creater.New(optionsExternalVersion.WithKind(getOptionsInternalKind.Kind))
 | 
							versionedGetOptions, err = a.group.Creater.New(optionsExternalVersion.WithKind(getOptionsInternalKind.Kind))
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
@@ -300,12 +304,16 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
 | 
				
			|||||||
	if isConnecter {
 | 
						if isConnecter {
 | 
				
			||||||
		connectOptions, connectSubpath, _ = connecter.NewConnectOptions()
 | 
							connectOptions, connectSubpath, _ = connecter.NewConnectOptions()
 | 
				
			||||||
		if connectOptions != nil {
 | 
							if connectOptions != nil {
 | 
				
			||||||
			connectOptionsInternalKind, err = a.group.Typer.ObjectKind(connectOptions)
 | 
								connectOptionsInternalKinds, _, err := a.group.Typer.ObjectKinds(connectOptions)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								connectOptionsInternalKind = connectOptionsInternalKinds[0]
 | 
				
			||||||
			versionedConnectOptions, err = a.group.Creater.New(optionsExternalVersion.WithKind(connectOptionsInternalKind.Kind))
 | 
								versionedConnectOptions, err = a.group.Creater.New(optionsExternalVersion.WithKind(connectOptionsInternalKind.Kind))
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -939,10 +939,11 @@ func finishRequest(timeout time.Duration, fn resultFunc) (result runtime.Object,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// transformDecodeError adds additional information when a decode fails.
 | 
					// transformDecodeError adds additional information when a decode fails.
 | 
				
			||||||
func transformDecodeError(typer runtime.ObjectTyper, baseErr error, into runtime.Object, gvk *unversioned.GroupVersionKind, body []byte) error {
 | 
					func transformDecodeError(typer runtime.ObjectTyper, baseErr error, into runtime.Object, gvk *unversioned.GroupVersionKind, body []byte) error {
 | 
				
			||||||
	objGVK, err := typer.ObjectKind(into)
 | 
						objGVKs, _, err := typer.ObjectKinds(into)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						objGVK := objGVKs[0]
 | 
				
			||||||
	if gvk != nil && len(gvk.Kind) > 0 {
 | 
						if gvk != nil && len(gvk.Kind) > 0 {
 | 
				
			||||||
		return errors.NewBadRequest(fmt.Sprintf("%s in version %q cannot be handled as a %s: %v", gvk.Kind, gvk.Version, objGVK.Kind, baseErr))
 | 
							return errors.NewBadRequest(fmt.Sprintf("%s in version %q cannot be handled as a %s: %v", gvk.Kind, gvk.Version, objGVK.Kind, baseErr))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,11 +210,11 @@ func (o objects) Kind(kind unversioned.GroupVersionKind, name string) (runtime.O
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (o objects) Add(obj runtime.Object) error {
 | 
					func (o objects) Add(obj runtime.Object) error {
 | 
				
			||||||
	gvk, err := o.scheme.ObjectKind(obj)
 | 
						gvks, _, err := o.scheme.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	kind := gvk.Kind
 | 
						kind := gvks[0].Kind
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case meta.IsListType(obj):
 | 
						case meta.IsListType(obj):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,28 +76,15 @@ func NewObjectTyper(resources []*unversioned.APIResourceList) (runtime.ObjectTyp
 | 
				
			|||||||
	return ot, nil
 | 
						return ot, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ObjectKind returns the group,version,kind of the provided object,
 | 
					 | 
				
			||||||
// or an error if the object in not *runtime.Unstructured or has no
 | 
					 | 
				
			||||||
// group,version,kind information.
 | 
					 | 
				
			||||||
func (ot *ObjectTyper) ObjectKind(obj runtime.Object) (unversioned.GroupVersionKind, error) {
 | 
					 | 
				
			||||||
	if _, ok := obj.(*runtime.Unstructured); !ok {
 | 
					 | 
				
			||||||
		return unversioned.GroupVersionKind{}, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return obj.GetObjectKind().GroupVersionKind(), nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// ObjectKinds returns a slice of one element with the
 | 
					// ObjectKinds returns a slice of one element with the
 | 
				
			||||||
// group,version,kind of the provided object, or an error if the
 | 
					// group,version,kind of the provided object, or an error if the
 | 
				
			||||||
// object is not *runtime.Unstructured or has no group,version,kind
 | 
					// object is not *runtime.Unstructured or has no group,version,kind
 | 
				
			||||||
// information.
 | 
					// information.
 | 
				
			||||||
func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersionKind, error) {
 | 
					func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersionKind, bool, error) {
 | 
				
			||||||
	gvk, err := ot.ObjectKind(obj)
 | 
						if _, ok := obj.(*runtime.Unstructured); !ok {
 | 
				
			||||||
	if err != nil {
 | 
							return nil, false, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return []unversioned.GroupVersionKind{obj.GetObjectKind().GroupVersionKind()}, false, nil
 | 
				
			||||||
	return []unversioned.GroupVersionKind{gvk}, nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Recognizes returns true if the provided group,version,kind was in
 | 
					// Recognizes returns true if the provided group,version,kind was in
 | 
				
			||||||
@@ -105,15 +92,3 @@ func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersi
 | 
				
			|||||||
func (ot *ObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool {
 | 
					func (ot *ObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool {
 | 
				
			||||||
	return ot.registered[gvk]
 | 
						return ot.registered[gvk]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// IsUnversioned returns false always because *runtime.Unstructured
 | 
					 | 
				
			||||||
// objects should always have group,version,kind information set. ok
 | 
					 | 
				
			||||||
// will be true if the object's group,version,kind is registered.
 | 
					 | 
				
			||||||
func (ot *ObjectTyper) IsUnversioned(obj runtime.Object) (unversioned bool, ok bool) {
 | 
					 | 
				
			||||||
	gvk, err := ot.ObjectKind(obj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return false, false
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return false, ot.registered[gvk]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ var Versions = []string{"v1"}
 | 
				
			|||||||
var Codec runtime.Codec
 | 
					var Codec runtime.Codec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
 | 
						yamlSerializer := json.NewYAMLSerializer(json.DefaultMetaFactory, api.Scheme, api.Scheme)
 | 
				
			||||||
	Codec = versioning.NewCodecForScheme(
 | 
						Codec = versioning.NewCodecForScheme(
 | 
				
			||||||
		api.Scheme,
 | 
							api.Scheme,
 | 
				
			||||||
		yamlSerializer,
 | 
							yamlSerializer,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -204,11 +204,11 @@ func (o objects) Kind(kind unversioned.GroupVersionKind, name string) (runtime.O
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (o objects) Add(obj runtime.Object) error {
 | 
					func (o objects) Add(obj runtime.Object) error {
 | 
				
			||||||
	gvk, err := o.scheme.ObjectKind(obj)
 | 
						gvks, _, err := o.scheme.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	kind := gvk.Kind
 | 
						kind := gvks[0].Kind
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case meta.IsListType(obj):
 | 
						case meta.IsListType(obj):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -220,11 +220,11 @@ func validateFields(a, b string) bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (c *Client) body(t *testing.T, obj runtime.Object, raw *string) *string {
 | 
					func (c *Client) body(t *testing.T, obj runtime.Object, raw *string) *string {
 | 
				
			||||||
	if obj != nil {
 | 
						if obj != nil {
 | 
				
			||||||
		fqKind, err := api.Scheme.ObjectKind(obj)
 | 
							fqKinds, _, err := api.Scheme.ObjectKinds(obj)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			t.Errorf("unexpected encoding error: %v", err)
 | 
								t.Errorf("unexpected encoding error: %v", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		groupName := fqKind.GroupVersion().Group
 | 
							groupName := fqKinds[0].GroupVersion().Group
 | 
				
			||||||
		if c.ResourceGroup != "" {
 | 
							if c.ResourceGroup != "" {
 | 
				
			||||||
			groupName = c.ResourceGroup
 | 
								groupName = c.ResourceGroup
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -320,11 +320,11 @@ func NewAPIFactory() (*cmdutil.Factory, *testFactory, runtime.Codec) {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				return c.Pods(t.Namespace).GetLogs(t.Name, opts), nil
 | 
									return c.Pods(t.Namespace).GetLogs(t.Name, opts), nil
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				fqKind, err := api.Scheme.ObjectKind(object)
 | 
									fqKinds, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return nil, fmt.Errorf("cannot get the logs from %v", fqKind)
 | 
									return nil, fmt.Errorf("cannot get the logs from %v", fqKinds[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -225,7 +225,11 @@ func RunCreateSubcommand(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer,
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mapper, typer := f.Object(cmdutil.GetIncludeThirdPartyAPIs(cmd))
 | 
						mapper, typer := f.Object(cmdutil.GetIncludeThirdPartyAPIs(cmd))
 | 
				
			||||||
	gvk, err := typer.ObjectKind(obj)
 | 
						gvks, _, err := typer.ObjectKinds(obj)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						gvk := gvks[0]
 | 
				
			||||||
	mapping, err := mapper.RESTMapping(unversioned.GroupKind{Group: gvk.Group, Kind: gvk.Kind}, gvk.Version)
 | 
						mapping, err := mapper.RESTMapping(unversioned.GroupKind{Group: gvk.Group, Kind: gvk.Kind}, gvk.Version)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -221,8 +221,8 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		newRc, ok = obj.(*api.ReplicationController)
 | 
							newRc, ok = obj.(*api.ReplicationController)
 | 
				
			||||||
		if !ok {
 | 
							if !ok {
 | 
				
			||||||
			if gvk, err := typer.ObjectKind(obj); err == nil {
 | 
								if gvks, _, err := typer.ObjectKinds(obj); err == nil {
 | 
				
			||||||
				return cmdutil.UsageError(cmd, "%s contains a %v not a ReplicationController", filename, gvk)
 | 
									return cmdutil.UsageError(cmd, "%s contains a %v not a ReplicationController", filename, gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			glog.V(4).Infof("Object %#v is not a ReplicationController", obj)
 | 
								glog.V(4).Infof("Object %#v is not a ReplicationController", obj)
 | 
				
			||||||
			return cmdutil.UsageError(cmd, "%s does not specify a valid ReplicationController", filename)
 | 
								return cmdutil.UsageError(cmd, "%s does not specify a valid ReplicationController", filename)
 | 
				
			||||||
@@ -377,11 +377,11 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
 | 
				
			|||||||
	if outputFormat != "" {
 | 
						if outputFormat != "" {
 | 
				
			||||||
		return f.PrintObject(cmd, mapper, newRc, out)
 | 
							return f.PrintObject(cmd, mapper, newRc, out)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	kind, err := api.Scheme.ObjectKind(newRc)
 | 
						kinds, _, err := api.Scheme.ObjectKinds(newRc)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	_, res := meta.KindToResource(kind)
 | 
						_, res := meta.KindToResource(kinds[0])
 | 
				
			||||||
	cmdutil.PrintSuccess(mapper, false, out, res.Resource, oldName, message)
 | 
						cmdutil.PrintSuccess(mapper, false, out, res.Resource, oldName, message)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -443,10 +443,11 @@ func createGeneratedObject(f *cmdutil.Factory, cmd *cobra.Command, generator kub
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mapper, typer := f.Object(cmdutil.GetIncludeThirdPartyAPIs(cmd))
 | 
						mapper, typer := f.Object(cmdutil.GetIncludeThirdPartyAPIs(cmd))
 | 
				
			||||||
	groupVersionKind, err := typer.ObjectKind(obj)
 | 
						groupVersionKinds, _, err := typer.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, "", nil, nil, err
 | 
							return nil, "", nil, nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						groupVersionKind := groupVersionKinds[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(overrides) > 0 {
 | 
						if len(overrides) > 0 {
 | 
				
			||||||
		codec := runtime.NewCodec(f.JSONEncoder(), f.Decoder(true))
 | 
							codec := runtime.NewCodec(f.JSONEncoder(), f.Decoder(true))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -419,11 +419,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				return kubectl.MakeLabels(t.Spec.Selector.MatchLabels), nil
 | 
									return kubectl.MakeLabels(t.Spec.Selector.MatchLabels), nil
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return "", err
 | 
										return "", err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return "", fmt.Errorf("cannot extract pod selector from %v", gvk)
 | 
									return "", fmt.Errorf("cannot extract pod selector from %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		PortsForObject: func(object runtime.Object) ([]string, error) {
 | 
							PortsForObject: func(object runtime.Object) ([]string, error) {
 | 
				
			||||||
@@ -440,11 +440,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
			case *extensions.ReplicaSet:
 | 
								case *extensions.ReplicaSet:
 | 
				
			||||||
				return getPorts(t.Spec.Template.Spec), nil
 | 
									return getPorts(t.Spec.Template.Spec), nil
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return nil, fmt.Errorf("cannot extract ports from %v", gvk)
 | 
									return nil, fmt.Errorf("cannot extract ports from %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ProtocolsForObject: func(object runtime.Object) (map[string]string, error) {
 | 
							ProtocolsForObject: func(object runtime.Object) (map[string]string, error) {
 | 
				
			||||||
@@ -461,11 +461,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
			case *extensions.ReplicaSet:
 | 
								case *extensions.ReplicaSet:
 | 
				
			||||||
				return getProtocols(t.Spec.Template.Spec), nil
 | 
									return getProtocols(t.Spec.Template.Spec), nil
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return nil, fmt.Errorf("cannot extract protocols from %v", gvk)
 | 
									return nil, fmt.Errorf("cannot extract protocols from %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		LabelsForObject: func(object runtime.Object) (map[string]string, error) {
 | 
							LabelsForObject: func(object runtime.Object) (map[string]string, error) {
 | 
				
			||||||
@@ -523,11 +523,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
				return c.Pods(pod.Namespace).GetLogs(pod.Name, opts), nil
 | 
									return c.Pods(pod.Namespace).GetLogs(pod.Name, opts), nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return nil, fmt.Errorf("cannot get the logs from %v", gvk)
 | 
									return nil, fmt.Errorf("cannot get the logs from %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		PauseObject: func(object runtime.Object) (bool, error) {
 | 
							PauseObject: func(object runtime.Object) (bool, error) {
 | 
				
			||||||
@@ -545,11 +545,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
				_, err := c.Extensions().Deployments(t.Namespace).Update(t)
 | 
									_, err := c.Extensions().Deployments(t.Namespace).Update(t)
 | 
				
			||||||
				return false, err
 | 
									return false, err
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return false, err
 | 
										return false, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return false, fmt.Errorf("cannot pause %v", gvk)
 | 
									return false, fmt.Errorf("cannot pause %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ResumeObject: func(object runtime.Object) (bool, error) {
 | 
							ResumeObject: func(object runtime.Object) (bool, error) {
 | 
				
			||||||
@@ -567,11 +567,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
				_, err := c.Extensions().Deployments(t.Namespace).Update(t)
 | 
									_, err := c.Extensions().Deployments(t.Namespace).Update(t)
 | 
				
			||||||
				return false, err
 | 
									return false, err
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return false, err
 | 
										return false, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return false, fmt.Errorf("cannot resume %v", gvk)
 | 
									return false, fmt.Errorf("cannot resume %v", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Scaler: func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
 | 
							Scaler: func(mapping *meta.RESTMapping) (kubectl.Scaler, error) {
 | 
				
			||||||
@@ -704,11 +704,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
 | 
				
			|||||||
			case *api.Pod:
 | 
								case *api.Pod:
 | 
				
			||||||
				return t, nil
 | 
									return t, nil
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
				gvk, err := api.Scheme.ObjectKind(object)
 | 
									gvks, _, err := api.Scheme.ObjectKinds(object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return nil, fmt.Errorf("cannot attach to %v: not implemented", gvk)
 | 
									return nil, fmt.Errorf("cannot attach to %v: not implemented", gvks[0])
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// UpdatePodSpecForObject update the pod specification for the provided object
 | 
							// UpdatePodSpecForObject update the pod specification for the provided object
 | 
				
			||||||
@@ -1087,12 +1087,12 @@ func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// PrintObject prints an api object given command line flags to modify the output format
 | 
					// PrintObject prints an api object given command line flags to modify the output format
 | 
				
			||||||
func (f *Factory) PrintObject(cmd *cobra.Command, mapper meta.RESTMapper, obj runtime.Object, out io.Writer) error {
 | 
					func (f *Factory) PrintObject(cmd *cobra.Command, mapper meta.RESTMapper, obj runtime.Object, out io.Writer) error {
 | 
				
			||||||
	gvk, err := api.Scheme.ObjectKind(obj)
 | 
						gvks, _, err := api.Scheme.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mapping, err := mapper.RESTMapping(gvk.GroupKind())
 | 
						mapping, err := mapper.RESTMapping(gvks[0].GroupKind())
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,7 +96,7 @@ func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
 | 
				
			|||||||
// if the object cannot be introspected. Name and namespace will be set into Info
 | 
					// if the object cannot be introspected. Name and namespace will be set into Info
 | 
				
			||||||
// if the mapping's MetadataAccessor can retrieve them.
 | 
					// if the mapping's MetadataAccessor can retrieve them.
 | 
				
			||||||
func (m *Mapper) InfoForObject(obj runtime.Object, preferredGVKs []unversioned.GroupVersionKind) (*Info, error) {
 | 
					func (m *Mapper) InfoForObject(obj runtime.Object, preferredGVKs []unversioned.GroupVersionKind) (*Info, error) {
 | 
				
			||||||
	groupVersionKinds, err := m.ObjectKinds(obj)
 | 
						groupVersionKinds, _, err := m.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("unable to get type info from the object %q: %v", reflect.TypeOf(obj), err)
 | 
							return nil, fmt.Errorf("unable to get type info from the object %q: %v", reflect.TypeOf(obj), err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -251,7 +251,7 @@ func AsVersionedObjects(infos []*Info, version unversioned.GroupVersion, encoder
 | 
				
			|||||||
		// objects that are not part of api.Scheme must be converted to JSON
 | 
							// objects that are not part of api.Scheme must be converted to JSON
 | 
				
			||||||
		// TODO: convert to map[string]interface{}, attach to runtime.Unknown?
 | 
							// TODO: convert to map[string]interface{}, attach to runtime.Unknown?
 | 
				
			||||||
		if !version.IsEmpty() {
 | 
							if !version.IsEmpty() {
 | 
				
			||||||
			if _, err := api.Scheme.ObjectKind(info.Object); runtime.IsNotRegisteredError(err) {
 | 
								if _, _, err := api.Scheme.ObjectKinds(info.Object); runtime.IsNotRegisteredError(err) {
 | 
				
			||||||
				// TODO: ideally this would encode to version, but we don't expose multiple codecs here.
 | 
									// TODO: ideally this would encode to version, but we don't expose multiple codecs here.
 | 
				
			||||||
				data, err := runtime.Encode(encoder, info.Object)
 | 
									data, err := runtime.Encode(encoder, info.Object)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,8 @@ func GetPrinter(format, formatArgument string) (ResourcePrinter, bool, error) {
 | 
				
			|||||||
		printer = &YAMLPrinter{}
 | 
							printer = &YAMLPrinter{}
 | 
				
			||||||
	case "name":
 | 
						case "name":
 | 
				
			||||||
		printer = &NamePrinter{
 | 
							printer = &NamePrinter{
 | 
				
			||||||
			Typer:   runtime.ObjectTyperToTyper(api.Scheme),
 | 
								// TODO: this is wrong, these should be provided as an argument to GetPrinter
 | 
				
			||||||
 | 
								Typer:   api.Scheme,
 | 
				
			||||||
			Decoder: api.Codecs.UniversalDecoder(),
 | 
								Decoder: api.Codecs.UniversalDecoder(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "template", "go-template":
 | 
						case "template", "go-template":
 | 
				
			||||||
@@ -203,14 +204,12 @@ func (p *VersionedPrinter) HandledResources() []string {
 | 
				
			|||||||
// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
 | 
					// NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
 | 
				
			||||||
type NamePrinter struct {
 | 
					type NamePrinter struct {
 | 
				
			||||||
	Decoder runtime.Decoder
 | 
						Decoder runtime.Decoder
 | 
				
			||||||
	Typer   runtime.Typer
 | 
						Typer   runtime.ObjectTyper
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object
 | 
					// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object
 | 
				
			||||||
// and print "resource/name" pair. If the object is a List, print all items in it.
 | 
					// and print "resource/name" pair. If the object is a List, print all items in it.
 | 
				
			||||||
func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
 | 
					func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
 | 
				
			||||||
	gvk, _, _ := p.Typer.ObjectKind(obj)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if meta.IsListType(obj) {
 | 
						if meta.IsListType(obj) {
 | 
				
			||||||
		items, err := meta.ExtractList(obj)
 | 
							items, err := meta.ExtractList(obj)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
@@ -236,10 +235,9 @@ func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if gvk != nil {
 | 
						if gvks, _, err := p.Typer.ObjectKinds(obj); err == nil {
 | 
				
			||||||
		// TODO: this is wrong, it assumes that meta knows about all Kinds - should take a RESTMapper
 | 
							// TODO: this is wrong, it assumes that meta knows about all Kinds - should take a RESTMapper
 | 
				
			||||||
		_, resource := meta.KindToResource(*gvk)
 | 
							_, resource := meta.KindToResource(gvks[0])
 | 
				
			||||||
 | 
					 | 
				
			||||||
		fmt.Fprintf(w, "%s/%s\n", resource.Resource, name)
 | 
							fmt.Fprintf(w, "%s/%s\n", resource.Resource, name)
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		fmt.Fprintf(w, "<unknown>/%s\n", name)
 | 
							fmt.Fprintf(w, "<unknown>/%s\n", name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -466,7 +466,7 @@ func TestPrinters(t *testing.T) {
 | 
				
			|||||||
		"template2":            templatePrinter2,
 | 
							"template2":            templatePrinter2,
 | 
				
			||||||
		"jsonpath":             jsonpathPrinter,
 | 
							"jsonpath":             jsonpathPrinter,
 | 
				
			||||||
		"name": &NamePrinter{
 | 
							"name": &NamePrinter{
 | 
				
			||||||
			Typer:   runtime.ObjectTyperToTyper(api.Scheme),
 | 
								Typer:   api.Scheme,
 | 
				
			||||||
			Decoder: api.Codecs.UniversalDecoder(),
 | 
								Decoder: api.Codecs.UniversalDecoder(),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,10 +152,11 @@ func (t *Tester) TestWatch(valid runtime.Object, labelsPass, labelsFail []labels
 | 
				
			|||||||
// =============================================================================
 | 
					// =============================================================================
 | 
				
			||||||
// get codec based on runtime.Object
 | 
					// get codec based on runtime.Object
 | 
				
			||||||
func getCodec(obj runtime.Object) (runtime.Codec, error) {
 | 
					func getCodec(obj runtime.Object) (runtime.Codec, error) {
 | 
				
			||||||
	fqKind, err := api.Scheme.ObjectKind(obj)
 | 
						fqKinds, _, err := api.Scheme.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("unexpected encoding error: %v", err)
 | 
							return nil, fmt.Errorf("unexpected encoding error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						fqKind := fqKinds[0]
 | 
				
			||||||
	// TODO: caesarxuchao: we should detect which group an object belongs to
 | 
						// TODO: caesarxuchao: we should detect which group an object belongs to
 | 
				
			||||||
	// by using the version returned by Schem.ObjectVersionAndKind() once we
 | 
						// by using the version returned by Schem.ObjectVersionAndKind() once we
 | 
				
			||||||
	// split the schemes for internal objects.
 | 
						// split the schemes for internal objects.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,13 +78,13 @@ func EncodeOrDie(e Encoder, obj Object) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// UseOrCreateObject returns obj if the canonical ObjectKind returned by the provided typer matches gvk, or
 | 
					// UseOrCreateObject returns obj if the canonical ObjectKind returned by the provided typer matches gvk, or
 | 
				
			||||||
// invokes the ObjectCreator to instantiate a new gvk. Returns an error if the typer cannot find the object.
 | 
					// invokes the ObjectCreator to instantiate a new gvk. Returns an error if the typer cannot find the object.
 | 
				
			||||||
func UseOrCreateObject(t Typer, c ObjectCreater, gvk unversioned.GroupVersionKind, obj Object) (Object, error) {
 | 
					func UseOrCreateObject(t ObjectTyper, c ObjectCreater, gvk unversioned.GroupVersionKind, obj Object) (Object, error) {
 | 
				
			||||||
	if obj != nil {
 | 
						if obj != nil {
 | 
				
			||||||
		into, _, err := t.ObjectKind(obj)
 | 
							into, _, err := t.ObjectKinds(obj)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if gvk == *into {
 | 
							if gvk == into[0] {
 | 
				
			||||||
			return obj, nil
 | 
								return obj, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -116,7 +116,7 @@ func (n NoopDecoder) Decode(data []byte, gvk *unversioned.GroupVersionKind, into
 | 
				
			|||||||
// NewParameterCodec creates a ParameterCodec capable of transforming url values into versioned objects and back.
 | 
					// NewParameterCodec creates a ParameterCodec capable of transforming url values into versioned objects and back.
 | 
				
			||||||
func NewParameterCodec(scheme *Scheme) ParameterCodec {
 | 
					func NewParameterCodec(scheme *Scheme) ParameterCodec {
 | 
				
			||||||
	return ¶meterCodec{
 | 
						return ¶meterCodec{
 | 
				
			||||||
		typer:     ObjectTyperToTyper(scheme),
 | 
							typer:     scheme,
 | 
				
			||||||
		convertor: scheme,
 | 
							convertor: scheme,
 | 
				
			||||||
		creator:   scheme,
 | 
							creator:   scheme,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -124,7 +124,7 @@ func NewParameterCodec(scheme *Scheme) ParameterCodec {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// parameterCodec implements conversion to and from query parameters and objects.
 | 
					// parameterCodec implements conversion to and from query parameters and objects.
 | 
				
			||||||
type parameterCodec struct {
 | 
					type parameterCodec struct {
 | 
				
			||||||
	typer     Typer
 | 
						typer     ObjectTyper
 | 
				
			||||||
	convertor ObjectConvertor
 | 
						convertor ObjectConvertor
 | 
				
			||||||
	creator   ObjectCreater
 | 
						creator   ObjectCreater
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -137,10 +137,11 @@ func (c *parameterCodec) DecodeParameters(parameters url.Values, from unversione
 | 
				
			|||||||
	if len(parameters) == 0 {
 | 
						if len(parameters) == 0 {
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	targetGVK, _, err := c.typer.ObjectKind(into)
 | 
						targetGVKs, _, err := c.typer.ObjectKinds(into)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						targetGVK := targetGVKs[0]
 | 
				
			||||||
	if targetGVK.GroupVersion() == from {
 | 
						if targetGVK.GroupVersion() == from {
 | 
				
			||||||
		return c.convertor.Convert(¶meters, into)
 | 
							return c.convertor.Convert(¶meters, into)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -157,10 +158,11 @@ func (c *parameterCodec) DecodeParameters(parameters url.Values, from unversione
 | 
				
			|||||||
// EncodeParameters converts the provided object into the to version, then converts that object to url.Values.
 | 
					// EncodeParameters converts the provided object into the to version, then converts that object to url.Values.
 | 
				
			||||||
// Returns an error if conversion is not possible.
 | 
					// Returns an error if conversion is not possible.
 | 
				
			||||||
func (c *parameterCodec) EncodeParameters(obj Object, to unversioned.GroupVersion) (url.Values, error) {
 | 
					func (c *parameterCodec) EncodeParameters(obj Object, to unversioned.GroupVersion) (url.Values, error) {
 | 
				
			||||||
	gvk, _, err := c.typer.ObjectKind(obj)
 | 
						gvks, _, err := c.typer.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						gvk := gvks[0]
 | 
				
			||||||
	if to != gvk.GroupVersion() {
 | 
						if to != gvk.GroupVersion() {
 | 
				
			||||||
		out, err := c.convertor.ConvertToVersion(obj, to)
 | 
							out, err := c.convertor.ConvertToVersion(obj, to)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,28 +26,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/util/errors"
 | 
						"k8s.io/kubernetes/pkg/util/errors"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type objectTyperToTyper struct {
 | 
					 | 
				
			||||||
	typer ObjectTyper
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (t objectTyperToTyper) ObjectKind(obj Object) (*unversioned.GroupVersionKind, bool, error) {
 | 
					 | 
				
			||||||
	gvk, err := t.typer.ObjectKind(obj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, false, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	unversionedType, ok := t.typer.IsUnversioned(obj)
 | 
					 | 
				
			||||||
	if !ok {
 | 
					 | 
				
			||||||
		// ObjectTyper violates its contract
 | 
					 | 
				
			||||||
		return nil, false, fmt.Errorf("typer returned a kind for %v, but then reported it was not in the scheme with IsUnversioned", reflect.TypeOf(obj))
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return &gvk, unversionedType, nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// ObjectTyperToTyper casts the old typer interface to the new typer interface
 | 
					 | 
				
			||||||
func ObjectTyperToTyper(typer ObjectTyper) Typer {
 | 
					 | 
				
			||||||
	return objectTyperToTyper{typer: typer}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// unsafeObjectConvertor implements ObjectConvertor using the unsafe conversion path.
 | 
					// unsafeObjectConvertor implements ObjectConvertor using the unsafe conversion path.
 | 
				
			||||||
type unsafeObjectConvertor struct {
 | 
					type unsafeObjectConvertor struct {
 | 
				
			||||||
	*Scheme
 | 
						*Scheme
 | 
				
			||||||
@@ -195,19 +173,9 @@ type MultiObjectTyper []ObjectTyper
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var _ ObjectTyper = MultiObjectTyper{}
 | 
					var _ ObjectTyper = MultiObjectTyper{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m MultiObjectTyper) ObjectKind(obj Object) (gvk unversioned.GroupVersionKind, err error) {
 | 
					func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, unversionedType bool, err error) {
 | 
				
			||||||
	for _, t := range m {
 | 
						for _, t := range m {
 | 
				
			||||||
		gvk, err = t.ObjectKind(obj)
 | 
							gvks, unversionedType, err = t.ObjectKinds(obj)
 | 
				
			||||||
		if err == nil {
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m MultiObjectTyper) ObjectKinds(obj Object) (gvks []unversioned.GroupVersionKind, err error) {
 | 
					 | 
				
			||||||
	for _, t := range m {
 | 
					 | 
				
			||||||
		gvks, err = t.ObjectKinds(obj)
 | 
					 | 
				
			||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -224,15 +192,6 @@ func (m MultiObjectTyper) Recognizes(gvk unversioned.GroupVersionKind) bool {
 | 
				
			|||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m MultiObjectTyper) IsUnversioned(obj Object) (bool, bool) {
 | 
					 | 
				
			||||||
	for _, t := range m {
 | 
					 | 
				
			||||||
		if unversioned, ok := t.IsUnversioned(obj); ok {
 | 
					 | 
				
			||||||
			return unversioned, true
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return false, false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// SetZeroValue would set the object of objPtr to zero value of its type.
 | 
					// SetZeroValue would set the object of objPtr to zero value of its type.
 | 
				
			||||||
func SetZeroValue(objPtr Object) error {
 | 
					func SetZeroValue(objPtr Object) error {
 | 
				
			||||||
	v, err := conversion.EnforcePtr(objPtr)
 | 
						v, err := conversion.EnforcePtr(objPtr)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,15 +30,6 @@ const (
 | 
				
			|||||||
	APIVersionInternal = "__internal"
 | 
						APIVersionInternal = "__internal"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Typer retrieves information about an object's group, version, and kind.
 | 
					 | 
				
			||||||
type Typer interface {
 | 
					 | 
				
			||||||
	// ObjectKind returns the version and kind of the provided object, or an
 | 
					 | 
				
			||||||
	// error if the object is not recognized (IsNotRegisteredError will return true).
 | 
					 | 
				
			||||||
	// It returns whether the object is considered unversioned at the same time.
 | 
					 | 
				
			||||||
	// TODO: align the signature of ObjectTyper with this interface
 | 
					 | 
				
			||||||
	ObjectKind(Object) (*unversioned.GroupVersionKind, bool, error)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type Encoder interface {
 | 
					type Encoder interface {
 | 
				
			||||||
	// EncodeToStream writes an object to a stream. Override versions may be provided for each group
 | 
						// EncodeToStream writes an object to a stream. Override versions may be provided for each group
 | 
				
			||||||
	// that enforce a certain versioning. Implementations may return errors if the versions are incompatible,
 | 
						// that enforce a certain versioning. Implementations may return errors if the versions are incompatible,
 | 
				
			||||||
@@ -178,20 +169,14 @@ type ObjectConvertor interface {
 | 
				
			|||||||
// ObjectTyper contains methods for extracting the APIVersion and Kind
 | 
					// ObjectTyper contains methods for extracting the APIVersion and Kind
 | 
				
			||||||
// of objects.
 | 
					// of objects.
 | 
				
			||||||
type ObjectTyper interface {
 | 
					type ObjectTyper interface {
 | 
				
			||||||
	// ObjectKind returns the default group,version,kind of the provided object, or an
 | 
						// ObjectKinds returns the all possible group,version,kind of the provided object, true if
 | 
				
			||||||
	// error if the object is not recognized (IsNotRegisteredError will return true).
 | 
						// the object is unversioned, or an error if the object is not recognized
 | 
				
			||||||
	ObjectKind(Object) (unversioned.GroupVersionKind, error)
 | 
						// (IsNotRegisteredError will return true).
 | 
				
			||||||
	// ObjectKinds returns the all possible group,version,kind of the provided object, or an
 | 
						ObjectKinds(Object) ([]unversioned.GroupVersionKind, bool, error)
 | 
				
			||||||
	// error if the object is not recognized (IsNotRegisteredError will return true).
 | 
					 | 
				
			||||||
	ObjectKinds(Object) ([]unversioned.GroupVersionKind, error)
 | 
					 | 
				
			||||||
	// Recognizes returns true if the scheme is able to handle the provided version and kind,
 | 
						// Recognizes returns true if the scheme is able to handle the provided version and kind,
 | 
				
			||||||
	// or more precisely that the provided version is a possible conversion or decoding
 | 
						// or more precisely that the provided version is a possible conversion or decoding
 | 
				
			||||||
	// target.
 | 
						// target.
 | 
				
			||||||
	Recognizes(gvk unversioned.GroupVersionKind) bool
 | 
						Recognizes(gvk unversioned.GroupVersionKind) bool
 | 
				
			||||||
	// IsUnversioned returns true if the provided object is considered unversioned and thus
 | 
					 | 
				
			||||||
	// should have Version and Group suppressed in the output. If the object is not recognized
 | 
					 | 
				
			||||||
	// in the scheme, ok is false.
 | 
					 | 
				
			||||||
	IsUnversioned(Object) (unversioned bool, ok bool)
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ObjectCreater contains methods for instantiating an object by kind and version.
 | 
					// ObjectCreater contains methods for instantiating an object by kind and version.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -211,31 +211,32 @@ func (s *Scheme) KnownTypes(gv unversioned.GroupVersion) map[string]reflect.Type
 | 
				
			|||||||
	return types
 | 
						return types
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ObjectKind returns the group,version,kind of the go object,
 | 
					// ObjectKind returns the group,version,kind of the go object and true if this object
 | 
				
			||||||
// or an error if it's not a pointer or is unregistered.
 | 
					// is considered unversioned, or an error if it's not a pointer or is unregistered.
 | 
				
			||||||
func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, error) {
 | 
					func (s *Scheme) ObjectKind(obj Object) (unversioned.GroupVersionKind, bool, error) {
 | 
				
			||||||
	gvks, err := s.ObjectKinds(obj)
 | 
						gvks, unversionedType, err := s.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return unversioned.GroupVersionKind{}, err
 | 
							return unversioned.GroupVersionKind{}, false, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return gvks[0], nil
 | 
						return gvks[0], unversionedType, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ObjectKinds returns all possible group,version,kind of the go object,
 | 
					// ObjectKinds returns all possible group,version,kind of the go object, true if the
 | 
				
			||||||
// or an error if it's not a pointer or is unregistered.
 | 
					// object is considered unversioned, or an error if it's not a pointer or is unregistered.
 | 
				
			||||||
func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, error) {
 | 
					func (s *Scheme) ObjectKinds(obj Object) ([]unversioned.GroupVersionKind, bool, error) {
 | 
				
			||||||
	v, err := conversion.EnforcePtr(obj)
 | 
						v, err := conversion.EnforcePtr(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, false, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	t := v.Type()
 | 
						t := v.Type()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gvks, ok := s.typeToGVK[t]
 | 
						gvks, ok := s.typeToGVK[t]
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
		return nil, ¬RegisteredErr{t: t}
 | 
							return nil, false, ¬RegisteredErr{t: t}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						_, unversionedType := s.unversionedTypes[t]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return gvks, nil
 | 
						return gvks, unversionedType, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Recognizes returns true if the scheme is able to handle the provided group,version,kind
 | 
					// Recognizes returns true if the scheme is able to handle the provided group,version,kind
 | 
				
			||||||
@@ -439,13 +440,13 @@ func (s *Scheme) Convert(in, out interface{}) error {
 | 
				
			|||||||
	inVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"}
 | 
						inVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"}
 | 
				
			||||||
	outVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"}
 | 
						outVersion := unversioned.GroupVersion{Group: "unknown", Version: "unknown"}
 | 
				
			||||||
	if inObj, ok := in.(Object); ok {
 | 
						if inObj, ok := in.(Object); ok {
 | 
				
			||||||
		if gvk, err := s.ObjectKind(inObj); err == nil {
 | 
							if gvks, _, err := s.ObjectKinds(inObj); err == nil {
 | 
				
			||||||
			inVersion = gvk.GroupVersion()
 | 
								inVersion = gvks[0].GroupVersion()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if outObj, ok := out.(Object); ok {
 | 
						if outObj, ok := out.(Object); ok {
 | 
				
			||||||
		if gvk, err := s.ObjectKind(outObj); err == nil {
 | 
							if gvks, _, err := s.ObjectKinds(outObj); err == nil {
 | 
				
			||||||
			outVersion = gvk.GroupVersion()
 | 
								outVersion = gvks[0].GroupVersion()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	flags, meta := s.generateConvertMeta(inVersion, outVersion, in)
 | 
						flags, meta := s.generateConvertMeta(inVersion, outVersion, in)
 | 
				
			||||||
@@ -504,7 +505,7 @@ func (s *Scheme) ConvertToVersion(in Object, outVersion unversioned.GroupVersion
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	outKind := outVersion.WithKind(kind.Kind)
 | 
						outKind := outVersion.WithKind(kind.Kind)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inKind, err := s.ObjectKind(in)
 | 
						inKinds, _, err := s.ObjectKinds(in)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -514,7 +515,7 @@ func (s *Scheme) ConvertToVersion(in Object, outVersion unversioned.GroupVersion
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flags, meta := s.generateConvertMeta(inKind.GroupVersion(), outVersion, in)
 | 
						flags, meta := s.generateConvertMeta(inKinds[0].GroupVersion(), outVersion, in)
 | 
				
			||||||
	if err := s.converter.Convert(in, out, flags, meta); err != nil {
 | 
						if err := s.converter.Convert(in, out, flags, meta); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -603,8 +604,11 @@ func setTargetVersion(obj Object, raw *Scheme, gv unversioned.GroupVersion) {
 | 
				
			|||||||
		obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{})
 | 
							obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{})
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	gvk, _ := raw.ObjectKind(obj)
 | 
						if gvks, _, _ := raw.ObjectKinds(obj); len(gvks) > 0 {
 | 
				
			||||||
	obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: gvk.Kind})
 | 
							obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: gvks[0].Kind})
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							obj.GetObjectKind().SetGroupVersionKind(unversioned.GroupVersionKind{Group: gv.Group, Version: gv.Version})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// setTargetKind sets the kind on an object, taking into account whether the target kind is the internal version.
 | 
					// setTargetKind sets the kind on an object, taking into account whether the target kind is the internal version.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -354,10 +354,11 @@ func TestUnversionedTypes(t *testing.T) {
 | 
				
			|||||||
		t.Fatalf("type not unversioned and in scheme: %t %t", unv, ok)
 | 
							t.Fatalf("type not unversioned and in scheme: %t %t", unv, ok)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kind, err := scheme.ObjectKind(&InternalSimple{})
 | 
						kinds, _, err := scheme.ObjectKinds(&InternalSimple{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						kind := kinds[0]
 | 
				
			||||||
	if kind != externalGV.WithKind("InternalSimple") {
 | 
						if kind != externalGV.WithKind("InternalSimple") {
 | 
				
			||||||
		t.Fatalf("unexpected: %#v", kind)
 | 
							t.Fatalf("unexpected: %#v", kind)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,9 +58,9 @@ type serializerType struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newSerializersForScheme(scheme *runtime.Scheme, mf json.MetaFactory) []serializerType {
 | 
					func newSerializersForScheme(scheme *runtime.Scheme, mf json.MetaFactory) []serializerType {
 | 
				
			||||||
	jsonSerializer := json.NewSerializer(mf, scheme, runtime.ObjectTyperToTyper(scheme), false)
 | 
						jsonSerializer := json.NewSerializer(mf, scheme, scheme, false)
 | 
				
			||||||
	jsonPrettySerializer := json.NewSerializer(mf, scheme, runtime.ObjectTyperToTyper(scheme), true)
 | 
						jsonPrettySerializer := json.NewSerializer(mf, scheme, scheme, true)
 | 
				
			||||||
	yamlSerializer := json.NewYAMLSerializer(mf, scheme, runtime.ObjectTyperToTyper(scheme))
 | 
						yamlSerializer := json.NewYAMLSerializer(mf, scheme, scheme)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	serializers := []serializerType{
 | 
						serializers := []serializerType{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer
 | 
					// NewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer
 | 
				
			||||||
// is not nil, the object has the group, version, and kind fields set.
 | 
					// is not nil, the object has the group, version, and kind fields set.
 | 
				
			||||||
func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer, pretty bool) *Serializer {
 | 
					func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper, pretty bool) *Serializer {
 | 
				
			||||||
	return &Serializer{
 | 
						return &Serializer{
 | 
				
			||||||
		meta:    meta,
 | 
							meta:    meta,
 | 
				
			||||||
		creater: creater,
 | 
							creater: creater,
 | 
				
			||||||
@@ -44,7 +44,7 @@ func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtim
 | 
				
			|||||||
// NewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer
 | 
					// NewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer
 | 
				
			||||||
// is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that
 | 
					// is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that
 | 
				
			||||||
// matches JSON, and will error if constructs are used that do not serialize to JSON.
 | 
					// matches JSON, and will error if constructs are used that do not serialize to JSON.
 | 
				
			||||||
func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer) *Serializer {
 | 
					func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.ObjectTyper) *Serializer {
 | 
				
			||||||
	return &Serializer{
 | 
						return &Serializer{
 | 
				
			||||||
		meta:    meta,
 | 
							meta:    meta,
 | 
				
			||||||
		creater: creater,
 | 
							creater: creater,
 | 
				
			||||||
@@ -56,7 +56,7 @@ func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer ru
 | 
				
			|||||||
type Serializer struct {
 | 
					type Serializer struct {
 | 
				
			||||||
	meta    MetaFactory
 | 
						meta    MetaFactory
 | 
				
			||||||
	creater runtime.ObjectCreater
 | 
						creater runtime.ObjectCreater
 | 
				
			||||||
	typer   runtime.Typer
 | 
						typer   runtime.ObjectTyper
 | 
				
			||||||
	yaml    bool
 | 
						yaml    bool
 | 
				
			||||||
	pretty  bool
 | 
						pretty  bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -116,7 +116,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKi
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if into != nil {
 | 
						if into != nil {
 | 
				
			||||||
		typed, _, err := s.typer.ObjectKind(into)
 | 
							types, _, err := s.typer.ObjectKinds(into)
 | 
				
			||||||
		switch {
 | 
							switch {
 | 
				
			||||||
		case runtime.IsNotRegisteredError(err):
 | 
							case runtime.IsNotRegisteredError(err):
 | 
				
			||||||
			if err := codec.NewDecoderBytes(data, new(codec.JsonHandle)).Decode(into); err != nil {
 | 
								if err := codec.NewDecoderBytes(data, new(codec.JsonHandle)).Decode(into); err != nil {
 | 
				
			||||||
@@ -126,6 +126,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKi
 | 
				
			|||||||
		case err != nil:
 | 
							case err != nil:
 | 
				
			||||||
			return nil, actual, err
 | 
								return nil, actual, err
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
 | 
								typed := types[0]
 | 
				
			||||||
			if len(actual.Kind) == 0 {
 | 
								if len(actual.Kind) == 0 {
 | 
				
			||||||
				actual.Kind = typed.Kind
 | 
									actual.Kind = typed.Kind
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,7 +41,7 @@ func (d *testDecodable) GroupVersionKind() unversioned.GroupVersionKind       {
 | 
				
			|||||||
func TestDecode(t *testing.T) {
 | 
					func TestDecode(t *testing.T) {
 | 
				
			||||||
	testCases := []struct {
 | 
						testCases := []struct {
 | 
				
			||||||
		creater runtime.ObjectCreater
 | 
							creater runtime.ObjectCreater
 | 
				
			||||||
		typer   runtime.Typer
 | 
							typer   runtime.ObjectTyper
 | 
				
			||||||
		yaml    bool
 | 
							yaml    bool
 | 
				
			||||||
		pretty  bool
 | 
							pretty  bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -260,6 +260,13 @@ type mockTyper struct {
 | 
				
			|||||||
	err error
 | 
						err error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (t *mockTyper) ObjectKind(obj runtime.Object) (*unversioned.GroupVersionKind, bool, error) {
 | 
					func (t *mockTyper) ObjectKinds(obj runtime.Object) ([]unversioned.GroupVersionKind, bool, error) {
 | 
				
			||||||
	return t.gvk, false, t.err
 | 
						if t.gvk == nil {
 | 
				
			||||||
 | 
							return nil, false, t.err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return []unversioned.GroupVersionKind{*t.gvk}, false, t.err
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (t *mockTyper) Recognizes(_ unversioned.GroupVersionKind) bool {
 | 
				
			||||||
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,7 +59,7 @@ func IsNotMarshalable(err error) bool {
 | 
				
			|||||||
// as-is (any type info passed with the object will be used).
 | 
					// as-is (any type info passed with the object will be used).
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// This encoding scheme is experimental, and is subject to change at any time.
 | 
					// This encoding scheme is experimental, and is subject to change at any time.
 | 
				
			||||||
func NewSerializer(creater runtime.ObjectCreater, typer runtime.Typer, defaultContentType string) *Serializer {
 | 
					func NewSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper, defaultContentType string) *Serializer {
 | 
				
			||||||
	return &Serializer{
 | 
						return &Serializer{
 | 
				
			||||||
		prefix:      protoEncodingPrefix,
 | 
							prefix:      protoEncodingPrefix,
 | 
				
			||||||
		creater:     creater,
 | 
							creater:     creater,
 | 
				
			||||||
@@ -71,7 +71,7 @@ func NewSerializer(creater runtime.ObjectCreater, typer runtime.Typer, defaultCo
 | 
				
			|||||||
type Serializer struct {
 | 
					type Serializer struct {
 | 
				
			||||||
	prefix      []byte
 | 
						prefix      []byte
 | 
				
			||||||
	creater     runtime.ObjectCreater
 | 
						creater     runtime.ObjectCreater
 | 
				
			||||||
	typer       runtime.Typer
 | 
						typer       runtime.ObjectTyper
 | 
				
			||||||
	contentType string
 | 
						contentType string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -131,7 +131,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKi
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if into != nil {
 | 
						if into != nil {
 | 
				
			||||||
		typed, _, err := s.typer.ObjectKind(into)
 | 
							types, _, err := s.typer.ObjectKinds(into)
 | 
				
			||||||
		switch {
 | 
							switch {
 | 
				
			||||||
		case runtime.IsNotRegisteredError(err):
 | 
							case runtime.IsNotRegisteredError(err):
 | 
				
			||||||
			pb, ok := into.(proto.Message)
 | 
								pb, ok := into.(proto.Message)
 | 
				
			||||||
@@ -145,12 +145,12 @@ func (s *Serializer) Decode(originalData []byte, gvk *unversioned.GroupVersionKi
 | 
				
			|||||||
		case err != nil:
 | 
							case err != nil:
 | 
				
			||||||
			return nil, &actual, err
 | 
								return nil, &actual, err
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			copyKindDefaults(&actual, typed)
 | 
								copyKindDefaults(&actual, &types[0])
 | 
				
			||||||
			// if the result of defaulting did not set a version or group, ensure that at least group is set
 | 
								// if the result of defaulting did not set a version or group, ensure that at least group is set
 | 
				
			||||||
			// (copyKindDefaults will not assign Group if version is already set). This guarantees that the group
 | 
								// (copyKindDefaults will not assign Group if version is already set). This guarantees that the group
 | 
				
			||||||
			// of into is set if there is no better information from the caller or object.
 | 
								// of into is set if there is no better information from the caller or object.
 | 
				
			||||||
			if len(actual.Version) == 0 && len(actual.Group) == 0 {
 | 
								if len(actual.Version) == 0 && len(actual.Group) == 0 {
 | 
				
			||||||
				actual.Group = typed.Group
 | 
									actual.Group = types[0].Group
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -277,7 +277,7 @@ func estimateUnknownSize(unk *runtime.Unknown, byteSize uint64) uint64 {
 | 
				
			|||||||
// encoded object, and thus is not self describing (callers must know what type is being described in order to decode).
 | 
					// encoded object, and thus is not self describing (callers must know what type is being described in order to decode).
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// This encoding scheme is experimental, and is subject to change at any time.
 | 
					// This encoding scheme is experimental, and is subject to change at any time.
 | 
				
			||||||
func NewRawSerializer(creater runtime.ObjectCreater, typer runtime.Typer, defaultContentType string) *RawSerializer {
 | 
					func NewRawSerializer(creater runtime.ObjectCreater, typer runtime.ObjectTyper, defaultContentType string) *RawSerializer {
 | 
				
			||||||
	return &RawSerializer{
 | 
						return &RawSerializer{
 | 
				
			||||||
		creater:     creater,
 | 
							creater:     creater,
 | 
				
			||||||
		typer:       typer,
 | 
							typer:       typer,
 | 
				
			||||||
@@ -289,7 +289,7 @@ func NewRawSerializer(creater runtime.ObjectCreater, typer runtime.Typer, defaul
 | 
				
			|||||||
// type).
 | 
					// type).
 | 
				
			||||||
type RawSerializer struct {
 | 
					type RawSerializer struct {
 | 
				
			||||||
	creater     runtime.ObjectCreater
 | 
						creater     runtime.ObjectCreater
 | 
				
			||||||
	typer       runtime.Typer
 | 
						typer       runtime.ObjectTyper
 | 
				
			||||||
	contentType string
 | 
						contentType string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -337,7 +337,7 @@ func (s *RawSerializer) Decode(originalData []byte, gvk *unversioned.GroupVersio
 | 
				
			|||||||
		return intoUnknown, actual, nil
 | 
							return intoUnknown, actual, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	typed, _, err := s.typer.ObjectKind(into)
 | 
						types, _, err := s.typer.ObjectKinds(into)
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case runtime.IsNotRegisteredError(err):
 | 
						case runtime.IsNotRegisteredError(err):
 | 
				
			||||||
		pb, ok := into.(proto.Message)
 | 
							pb, ok := into.(proto.Message)
 | 
				
			||||||
@@ -351,12 +351,12 @@ func (s *RawSerializer) Decode(originalData []byte, gvk *unversioned.GroupVersio
 | 
				
			|||||||
	case err != nil:
 | 
						case err != nil:
 | 
				
			||||||
		return nil, actual, err
 | 
							return nil, actual, err
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		copyKindDefaults(actual, typed)
 | 
							copyKindDefaults(actual, &types[0])
 | 
				
			||||||
		// if the result of defaulting did not set a version or group, ensure that at least group is set
 | 
							// if the result of defaulting did not set a version or group, ensure that at least group is set
 | 
				
			||||||
		// (copyKindDefaults will not assign Group if version is already set). This guarantees that the group
 | 
							// (copyKindDefaults will not assign Group if version is already set). This guarantees that the group
 | 
				
			||||||
		// of into is set if there is no better information from the caller or object.
 | 
							// of into is set if there is no better information from the caller or object.
 | 
				
			||||||
		if len(actual.Version) == 0 && len(actual.Group) == 0 {
 | 
							if len(actual.Version) == 0 && len(actual.Group) == 0 {
 | 
				
			||||||
			actual.Group = typed.Group
 | 
								actual.Group = types[0].Group
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -371,7 +371,7 @@ func (s *RawSerializer) Decode(originalData []byte, gvk *unversioned.GroupVersio
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// unmarshalToObject is the common code between decode in the raw and normal serializer.
 | 
					// unmarshalToObject is the common code between decode in the raw and normal serializer.
 | 
				
			||||||
func unmarshalToObject(typer runtime.Typer, creater runtime.ObjectCreater, actual *unversioned.GroupVersionKind, into runtime.Object, data []byte) (runtime.Object, *unversioned.GroupVersionKind, error) {
 | 
					func unmarshalToObject(typer runtime.ObjectTyper, creater runtime.ObjectCreater, actual *unversioned.GroupVersionKind, into runtime.Object, data []byte) (runtime.Object, *unversioned.GroupVersionKind, error) {
 | 
				
			||||||
	// use the target if necessary
 | 
						// use the target if necessary
 | 
				
			||||||
	obj, err := runtime.UseOrCreateObject(typer, creater, *actual, into)
 | 
						obj, err := runtime.UseOrCreateObject(typer, creater, *actual, into)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -323,7 +323,7 @@ func TestDecodeObjects(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i, test := range testCases {
 | 
						for i, test := range testCases {
 | 
				
			||||||
		s := protobuf.NewSerializer(api.Scheme, runtime.ObjectTyperToTyper(api.Scheme), "application/protobuf")
 | 
							s := protobuf.NewSerializer(api.Scheme, api.Scheme, "application/protobuf")
 | 
				
			||||||
		obj, err := runtime.Decode(s, test.data)
 | 
							obj, err := runtime.Decode(s, test.data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch {
 | 
							switch {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,8 +31,8 @@ const (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func protobufSerializer(scheme *runtime.Scheme) (serializerType, bool) {
 | 
					func protobufSerializer(scheme *runtime.Scheme) (serializerType, bool) {
 | 
				
			||||||
	serializer := protobuf.NewSerializer(scheme, runtime.ObjectTyperToTyper(scheme), contentTypeProtobuf)
 | 
						serializer := protobuf.NewSerializer(scheme, scheme, contentTypeProtobuf)
 | 
				
			||||||
	raw := protobuf.NewRawSerializer(scheme, runtime.ObjectTyperToTyper(scheme), contentTypeProtobuf)
 | 
						raw := protobuf.NewRawSerializer(scheme, scheme, contentTypeProtobuf)
 | 
				
			||||||
	return serializerType{
 | 
						return serializerType{
 | 
				
			||||||
		AcceptContentTypes: []string{contentTypeProtobuf},
 | 
							AcceptContentTypes: []string{contentTypeProtobuf},
 | 
				
			||||||
		ContentType:        contentTypeProtobuf,
 | 
							ContentType:        contentTypeProtobuf,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,8 +32,8 @@ func TestRecognizer(t *testing.T) {
 | 
				
			|||||||
	s := runtime.NewScheme()
 | 
						s := runtime.NewScheme()
 | 
				
			||||||
	s.AddKnownTypes(unversioned.GroupVersion{Version: "v1"}, &A{})
 | 
						s.AddKnownTypes(unversioned.GroupVersion{Version: "v1"}, &A{})
 | 
				
			||||||
	d := NewDecoder(
 | 
						d := NewDecoder(
 | 
				
			||||||
		json.NewSerializer(json.DefaultMetaFactory, s, runtime.ObjectTyperToTyper(s), false),
 | 
							json.NewSerializer(json.DefaultMetaFactory, s, s, false),
 | 
				
			||||||
		json.NewYAMLSerializer(json.DefaultMetaFactory, s, runtime.ObjectTyperToTyper(s)),
 | 
							json.NewYAMLSerializer(json.DefaultMetaFactory, s, s),
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	out, _, err := d.Decode([]byte(`
 | 
						out, _, err := d.Decode([]byte(`
 | 
				
			||||||
kind: A
 | 
					kind: A
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,7 +71,7 @@ func NewCodecForScheme(
 | 
				
			|||||||
	encodeVersion []unversioned.GroupVersion,
 | 
						encodeVersion []unversioned.GroupVersion,
 | 
				
			||||||
	decodeVersion []unversioned.GroupVersion,
 | 
						decodeVersion []unversioned.GroupVersion,
 | 
				
			||||||
) runtime.Codec {
 | 
					) runtime.Codec {
 | 
				
			||||||
	return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, runtime.ObjectTyperToTyper(scheme), encodeVersion, decodeVersion)
 | 
						return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, encodeVersion, decodeVersion)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewCodec takes objects in their internal versions and converts them to external versions before
 | 
					// NewCodec takes objects in their internal versions and converts them to external versions before
 | 
				
			||||||
@@ -83,7 +83,7 @@ func NewCodec(
 | 
				
			|||||||
	convertor runtime.ObjectConvertor,
 | 
						convertor runtime.ObjectConvertor,
 | 
				
			||||||
	creater runtime.ObjectCreater,
 | 
						creater runtime.ObjectCreater,
 | 
				
			||||||
	copier runtime.ObjectCopier,
 | 
						copier runtime.ObjectCopier,
 | 
				
			||||||
	typer runtime.Typer,
 | 
						typer runtime.ObjectTyper,
 | 
				
			||||||
	encodeVersion []unversioned.GroupVersion,
 | 
						encodeVersion []unversioned.GroupVersion,
 | 
				
			||||||
	decodeVersion []unversioned.GroupVersion,
 | 
						decodeVersion []unversioned.GroupVersion,
 | 
				
			||||||
) runtime.Codec {
 | 
					) runtime.Codec {
 | 
				
			||||||
@@ -130,7 +130,7 @@ type codec struct {
 | 
				
			|||||||
	convertor runtime.ObjectConvertor
 | 
						convertor runtime.ObjectConvertor
 | 
				
			||||||
	creater   runtime.ObjectCreater
 | 
						creater   runtime.ObjectCreater
 | 
				
			||||||
	copier    runtime.ObjectCopier
 | 
						copier    runtime.ObjectCopier
 | 
				
			||||||
	typer     runtime.Typer
 | 
						typer     runtime.ObjectTyper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	encodeVersion map[string]unversioned.GroupVersion
 | 
						encodeVersion map[string]unversioned.GroupVersion
 | 
				
			||||||
	decodeVersion map[string]unversioned.GroupVersion
 | 
						decodeVersion map[string]unversioned.GroupVersion
 | 
				
			||||||
@@ -228,15 +228,16 @@ func (c *codec) EncodeToStream(obj runtime.Object, w io.Writer, overrides ...unv
 | 
				
			|||||||
	if _, ok := obj.(*runtime.Unknown); ok {
 | 
						if _, ok := obj.(*runtime.Unknown); ok {
 | 
				
			||||||
		return c.encoder.EncodeToStream(obj, w, overrides...)
 | 
							return c.encoder.EncodeToStream(obj, w, overrides...)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	gvk, isUnversioned, err := c.typer.ObjectKind(obj)
 | 
						gvks, isUnversioned, err := c.typer.ObjectKinds(obj)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						gvk := gvks[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (c.encodeVersion == nil && len(overrides) == 0) || isUnversioned {
 | 
						if (c.encodeVersion == nil && len(overrides) == 0) || isUnversioned {
 | 
				
			||||||
		objectKind := obj.GetObjectKind()
 | 
							objectKind := obj.GetObjectKind()
 | 
				
			||||||
		old := objectKind.GroupVersionKind()
 | 
							old := objectKind.GroupVersionKind()
 | 
				
			||||||
		objectKind.SetGroupVersionKind(*gvk)
 | 
							objectKind.SetGroupVersionKind(gvk)
 | 
				
			||||||
		err = c.encoder.EncodeToStream(obj, w, overrides...)
 | 
							err = c.encoder.EncodeToStream(obj, w, overrides...)
 | 
				
			||||||
		objectKind.SetGroupVersionKind(old)
 | 
							objectKind.SetGroupVersionKind(old)
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ func TestDecode(t *testing.T) {
 | 
				
			|||||||
		convertor  runtime.ObjectConvertor
 | 
							convertor  runtime.ObjectConvertor
 | 
				
			||||||
		creater    runtime.ObjectCreater
 | 
							creater    runtime.ObjectCreater
 | 
				
			||||||
		copier     runtime.ObjectCopier
 | 
							copier     runtime.ObjectCopier
 | 
				
			||||||
		typer      runtime.Typer
 | 
							typer      runtime.ObjectTyper
 | 
				
			||||||
		yaml       bool
 | 
							yaml       bool
 | 
				
			||||||
		pretty     bool
 | 
							pretty     bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ var Versions = []string{"v1"}
 | 
				
			|||||||
var Codec runtime.Codec
 | 
					var Codec runtime.Codec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	jsonSerializer := json.NewSerializer(json.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme), true)
 | 
						jsonSerializer := json.NewSerializer(json.DefaultMetaFactory, api.Scheme, api.Scheme, true)
 | 
				
			||||||
	Codec = versioning.NewCodecForScheme(
 | 
						Codec = versioning.NewCodecForScheme(
 | 
				
			||||||
		api.Scheme,
 | 
							api.Scheme,
 | 
				
			||||||
		jsonSerializer,
 | 
							jsonSerializer,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,9 +59,9 @@ func (s *wrappedSerializer) UniversalDeserializer() runtime.Decoder {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *wrappedSerializer) EncoderForVersion(encoder runtime.Encoder, gv unversioned.GroupVersion) runtime.Encoder {
 | 
					func (s *wrappedSerializer) EncoderForVersion(encoder runtime.Encoder, gv unversioned.GroupVersion) runtime.Encoder {
 | 
				
			||||||
	return versioning.NewCodec(encoder, nil, s.scheme, s.scheme, s.scheme, runtime.ObjectTyperToTyper(s.scheme), []unversioned.GroupVersion{gv}, nil)
 | 
						return versioning.NewCodec(encoder, nil, s.scheme, s.scheme, s.scheme, s.scheme, []unversioned.GroupVersion{gv}, nil)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *wrappedSerializer) DecoderToVersion(decoder runtime.Decoder, gv unversioned.GroupVersion) runtime.Decoder {
 | 
					func (s *wrappedSerializer) DecoderToVersion(decoder runtime.Decoder, gv unversioned.GroupVersion) runtime.Decoder {
 | 
				
			||||||
	return versioning.NewCodec(nil, decoder, s.scheme, s.scheme, s.scheme, runtime.ObjectTyperToTyper(s.scheme), nil, []unversioned.GroupVersion{gv})
 | 
						return versioning.NewCodec(nil, decoder, s.scheme, s.scheme, s.scheme, s.scheme, nil, []unversioned.GroupVersion{gv})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user