Add custom conversion function system.

As an example, demonstrate how Env.Key's deprecation ought to work.
This commit is contained in:
Daniel Smith
2014-07-28 15:13:17 -07:00
parent dc6fdc423d
commit 242c8cdaec
9 changed files with 379 additions and 257 deletions

View File

@@ -28,11 +28,8 @@ func TestAPIObject(t *testing.T) {
Object APIObject `yaml:"object,omitempty" json:"object,omitempty"`
EmptyObject APIObject `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
}
convert := func(obj interface{}) (interface{}, error) { return obj, nil }
AddKnownTypes("", EmbeddedTest{})
AddKnownTypes("v1beta1", EmbeddedTest{})
AddExternalConversion("EmbeddedTest", convert)
AddInternalConversion("EmbeddedTest", convert)
outer := &EmbeddedTest{
JSONBase: JSONBase{ID: "outer"},