Add back fix for CRD patch creation

Signed-off-by: Adrian Gonzalez-Martin <agm@seldon.io>
pull/7269/head
Adrian Gonzalez-Martin 5 years ago
parent 02ad2b1187
commit afa612df9d

@ -355,7 +355,12 @@ func createPatch(target *resource.Info, current runtime.Object) ([]byte, types.P
// returned from ConvertToVersion. Anything that's unstructured should // returned from ConvertToVersion. Anything that's unstructured should
// use the jsonpatch.CreateMergePatch. Strategic Merge Patch is not supported // use the jsonpatch.CreateMergePatch. Strategic Merge Patch is not supported
// on objects like CRDs. // on objects like CRDs.
if _, ok := versionedObject.(runtime.Unstructured); ok { _, isUnstructured := versionedObject.(runtime.Unstructured)
// On newer K8s versions, CRDs aren't unstructured but has this dedicated type
_, isCRD := versionedObject.(*apiextv1beta1.CustomResourceDefinition)
if isUnstructured || isCRD {
// fall back to generic JSON merge patch // fall back to generic JSON merge patch
patch, err := jsonpatch.CreateMergePatch(oldData, newData) patch, err := jsonpatch.CreateMergePatch(oldData, newData)
return patch, types.MergePatchType, err return patch, types.MergePatchType, err

Loading…
Cancel
Save