mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
apimachinery: idempotent registration of unversioned types
This commit is contained in:
parent
3eca0b5ad0
commit
5ea58748f1
@ -151,8 +151,8 @@ func (s *Scheme) AddUnversionedTypes(version schema.GroupVersion, types ...Objec
|
|||||||
t := reflect.TypeOf(obj).Elem()
|
t := reflect.TypeOf(obj).Elem()
|
||||||
gvk := version.WithKind(t.Name())
|
gvk := version.WithKind(t.Name())
|
||||||
s.unversionedTypes[t] = gvk
|
s.unversionedTypes[t] = gvk
|
||||||
if _, ok := s.unversionedKinds[gvk.Kind]; ok {
|
if old, ok := s.unversionedKinds[gvk.Kind]; ok && t != old {
|
||||||
panic(fmt.Sprintf("%v has already been registered as unversioned kind %q - kind name must be unique", reflect.TypeOf(t), gvk.Kind))
|
panic(fmt.Sprintf("%v.%v has already been registered as unversioned kind %q - kind name must be unique", old.PkgPath(), old.Name(), gvk))
|
||||||
}
|
}
|
||||||
s.unversionedKinds[gvk.Kind] = t
|
s.unversionedKinds[gvk.Kind] = t
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user