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:
committed by
Darren Shepherd
parent
7fed8b17a8
commit
6a363d8e93
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user