Commit 29ff69fd authored by Michail Kargakis's avatar Michail Kargakis

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.
parent d0b887e4
......@@ -52,6 +52,9 @@ type Mapper struct {
func (m *Mapper) InfoForData(data []byte, source string) (*Info, error) {
versions := &runtime.VersionedObjects{}
_, 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 versioned runtime.Object
if registered.IsThirdPartyAPIGroupVersion(gvk.GroupVersion()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment