mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 22:20:18 +00:00
Remove unnecessary EmbeddedObjects
Clarify the tests in embedded_test.go to indicate that unmarshalling of an internal object (runtime.EmbeddedObject) will not work. Instead, consumers should decode raw external objects.
This commit is contained in:
@@ -20,47 +20,6 @@ import (
|
||||
"gopkg.in/v1/yaml"
|
||||
)
|
||||
|
||||
// EmbeddedObject must have an appropriate encoder and decoder functions, such that on the
|
||||
// wire, it's stored as a []byte, but in memory, the contained object is accessable as an
|
||||
// Object via the Get() function. Only valid API objects may be stored via EmbeddedObject.
|
||||
// The purpose of this is to allow an API object of type known only at runtime to be
|
||||
// embedded within other API objects.
|
||||
//
|
||||
// Define a Codec variable in your package and import the runtime package and
|
||||
// then use the commented section below
|
||||
|
||||
/*
|
||||
// EmbeddedObject implements a Codec specific version of an
|
||||
// embedded object.
|
||||
type EmbeddedObject struct {
|
||||
runtime.Object
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (a *EmbeddedObject) UnmarshalJSON(b []byte) error {
|
||||
obj, err := runtime.CodecUnmarshalJSON(Codec, b)
|
||||
a.Object = obj
|
||||
return err
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (a EmbeddedObject) MarshalJSON() ([]byte, error) {
|
||||
return runtime.CodecMarshalJSON(Codec, a.Object)
|
||||
}
|
||||
|
||||
// SetYAML implements the yaml.Setter interface.
|
||||
func (a *EmbeddedObject) SetYAML(tag string, value interface{}) bool {
|
||||
obj, ok := runtime.CodecSetYAML(Codec, tag, value)
|
||||
a.Object = obj
|
||||
return ok
|
||||
}
|
||||
|
||||
// GetYAML implements the yaml.Getter interface.
|
||||
func (a EmbeddedObject) GetYAML() (tag string, value interface{}) {
|
||||
return runtime.CodecGetYAML(Codec, a.Object)
|
||||
}
|
||||
*/
|
||||
|
||||
// Encode()/Decode() are the canonical way of converting an API object to/from
|
||||
// wire format. This file provides utility functions which permit doing so
|
||||
// recursively, such that API objects of types known only at run time can be
|
||||
|
Reference in New Issue
Block a user