fix edit of non-registered custom API types

This commit is contained in:
Philip Hamer 2021-11-09 10:06:03 -05:00
parent a9ad15c421
commit e07a6c9e52
No known key found for this signature in database
GPG Key ID: 7F55992EFA6F6C83

View File

@ -19,6 +19,7 @@ package editor
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
@ -667,8 +668,14 @@ func (o *EditOptions) visitToPatch(originalInfos []*resource.Info, patchVisitor
klog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
return err
}
var patchMap map[string]interface{}
err = json.Unmarshal(patch, &patchMap)
if err != nil {
klog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
return err
}
for _, precondition := range preconditions {
if !precondition(patch) {
if !precondition(patchMap) {
klog.V(4).Infof("Unable to calculate diff, no merge is possible: %v", err)
return fmt.Errorf("%s", "At least one of apiVersion, kind and name was changed")
}