1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-18 08:14:56 +00:00

Adding error if not a pointer

This change adds an early panic if the type of the obj supplied to the
`MustImport` func is a pointer.  This is to prevent a later, cryptic,
error that is not as clear to diagnose.
This commit is contained in:
Nathan Jenan
2018-04-30 09:36:53 -07:00
committed by Darren Shepherd
parent 7fed8b17a8
commit 6a363d8e93

View File

@@ -48,6 +48,10 @@ func (s *Schemas) AddMapperForType(version *APIVersion, obj interface{}, mapper
}
func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverrides ...interface{}) *Schemas {
if reflect.ValueOf(obj).Kind() == reflect.Ptr {
panic(fmt.Errorf("obj cannot be a pointer"))
}
if _, err := s.Import(version, obj, externalOverrides...); err != nil {
panic(err)
}