Skip to content

Commit

Permalink
Review Remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
trasc committed Oct 25, 2024
1 parent e652815 commit ab4e8c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/webhook/admission/defaulter_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ func (h *defaulterForType) dropSchemeRemovals(r Response, original runtime.Objec
return Errored(http.StatusInternalServerError, err)
}

patchOriginal := PatchResponseFromRaw(raw, marshalledOriginal).Patches
patchOriginal, err := jsonpatch.CreatePatch(raw, marshalledOriginal)
if err != nil {
return Errored(http.StatusInternalServerError, err)
}
removedByScheme := sets.New(slices.DeleteFunc(patchOriginal, func(p jsonpatch.JsonPatchOperation) bool { return p.Operation != opRemove })...)

r.Patches = slices.DeleteFunc(r.Patches, func(p jsonpatch.JsonPatchOperation) bool {
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhook/admission/defaulter_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

var _ = Describe("Defaulter Handler", func() {

It("should not preserve unknown fields by default", func() {
It("should remove unknown fields when DefaulterRemoveUnknownFields is passed", func() {
obj := &TestDefaulter{}
handler := WithCustomDefaulter(admissionScheme, obj, &TestCustomDefaulter{}, DefaulterRemoveUnknownFields)

Expand Down Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Defaulter Handler", func() {
Expect(resp.Result.Code).Should(Equal(int32(http.StatusOK)))
})

It("should preserve unknown fields when DefaulterPreserveUnknownFields is passed", func() {
It("should preserve unknown fields by default", func() {
obj := &TestDefaulter{}
handler := WithCustomDefaulter(admissionScheme, obj, &TestCustomDefaulter{})

Expand Down

0 comments on commit ab4e8c9

Please sign in to comment.