Skip to content

Commit

Permalink
Merge pull request #1299 from zlabjp/deal-with-empty-patch
Browse files Browse the repository at this point in the history
馃悰 Do not set PatchType if patch is empty
  • Loading branch information
k8s-ci-robot committed Dec 17, 2020
2 parents 355962a + 66972d3 commit cf7ac88
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/webhook/admission/response.go
Expand Up @@ -90,8 +90,14 @@ func PatchResponseFromRaw(original, current []byte) Response {
return Response{
Patches: patches,
AdmissionResponse: admissionv1.AdmissionResponse{
Allowed: true,
PatchType: func() *admissionv1.PatchType { pt := admissionv1.PatchTypeJSONPatch; return &pt }(),
Allowed: true,
PatchType: func() *admissionv1.PatchType {
if len(patches) == 0 {
return nil
}
pt := admissionv1.PatchTypeJSONPatch
return &pt
}(),
},
}
}
Expand Down

0 comments on commit cf7ac88

Please sign in to comment.