Skip to content

Commit cf7ac88

Browse files
authored
Merge pull request #1299 from zlabjp/deal-with-empty-patch
🐛 Do not set PatchType if patch is empty
2 parents 355962a + 66972d3 commit cf7ac88

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/webhook/admission/response.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,14 @@ func PatchResponseFromRaw(original, current []byte) Response {
9090
return Response{
9191
Patches: patches,
9292
AdmissionResponse: admissionv1.AdmissionResponse{
93-
Allowed: true,
94-
PatchType: func() *admissionv1.PatchType { pt := admissionv1.PatchTypeJSONPatch; return &pt }(),
93+
Allowed: true,
94+
PatchType: func() *admissionv1.PatchType {
95+
if len(patches) == 0 {
96+
return nil
97+
}
98+
pt := admissionv1.PatchTypeJSONPatch
99+
return &pt
100+
}(),
95101
},
96102
}
97103
}

0 commit comments

Comments
 (0)