mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
kubectl: avoid panic with nil gvk
The decoder will return a nil gvk in case it errors out and getting the version out of that gvk naturally will panic. Bail out as soon as we can check that the error is non-nil. kubectl edit was the primary victim.
This commit is contained in:
parent
d0b887e4e0
commit
29ff69fd83
@ -52,6 +52,9 @@ type Mapper struct {
|
|||||||
func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
|
func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
|
||||||
versions := &runtime.VersionedObjects{}
|
versions := &runtime.VersionedObjects{}
|
||||||
_, gvk, err := m.Decode(data, nil, versions)
|
_, gvk, err := m.Decode(data, nil, versions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to decode %q: %v", source, err)
|
||||||
|
}
|
||||||
var obj runtime.Object
|
var obj runtime.Object
|
||||||
var versioned runtime.Object
|
var versioned runtime.Object
|
||||||
if registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
|
if registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user