Merge pull request #1584 from CharlesQQ/master

fix: bugfix response's patch and patchType is nil, controller panic
This commit is contained in:
karmada-bot 2022-04-07 10:07:47 +08:00 committed by GitHub
commit 756fd12dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -252,6 +252,9 @@ func (e *CustomizedInterpreter) callHook(ctx context.Context, hook configmanager
func applyPatch(object *unstructured.Unstructured, patch []byte, patchType configv1alpha1.PatchType) (*unstructured.Unstructured, error) {
switch patchType {
case configv1alpha1.PatchTypeJSONPatch:
if len(patch) == 0 {
return object, nil
}
patchObj, err := jsonpatch.DecodePatch(patch)
if err != nil {
return nil, err

View File

@ -107,7 +107,9 @@ func verifyResourceInterpreterContext(operation configv1alpha1.InterpreterOperat
return nil, err
}
res.Patch = response.Patch
res.PatchType = *response.PatchType
if response.PatchType != nil {
res.PatchType = *response.PatchType
}
return res, nil
case configv1alpha1.InterpreterOperationInterpretStatus:
res.RawStatus = *response.RawStatus