ObjectMeta, ListMeta, and TypeMeta should implement their interfaces

Make unversioned.ListMeta implement List. Update all the *List types so they implement GetListMeta.
This helps avoid using reflection to get list information.

Remove all unnecessary boilerplate, move the interfaces to the right
places, and add a test that verifies that objects implement one, the
other, but never both.
This commit is contained in:
Andy Goldstein
2016-05-26 14:17:14 -04:00
committed by Clayton Coleman
parent 64b4967774
commit e3af3451c8
25 changed files with 237 additions and 254 deletions

View File

@@ -35,6 +35,11 @@ func ListAccessor(obj interface{}) (List, error) {
return om, nil
}
}
if listMetaAccessor, ok := obj.(unversioned.ListMetaAccessor); ok {
if om := listMetaAccessor.GetListMeta(); om != nil {
return om, nil
}
}
// we may get passed an object that is directly portable to List
if list, ok := obj.(List); ok {
return list, nil