Allow mismatched type names on all conversions

Allows v1beta3.Node to be converted to api.Minion
This commit is contained in:
Clayton Coleman
2014-12-07 22:31:07 -05:00
parent edeb96dca9
commit 279df03377
3 changed files with 42 additions and 6 deletions

View File

@@ -75,10 +75,12 @@ func (s *Scheme) Log(l DebugLogger) {
// nameFunc returns the name of the type that we wish to use for encoding. Defaults to
// the go name of the type if the type is not registered.
func (s *Scheme) nameFunc(t reflect.Type) string {
if kind, ok := s.typeToKind[t]; ok {
return kind[0]
// find the preferred names for this type
names, ok := s.typeToKind[t]
if !ok {
return t.Name()
}
return t.Name()
return names[0]
}
// AddKnownTypes registers all types passed in 'types' as being members of version 'version.