Skip to content

Commit abe8a6e

Browse files
committed
ForceOwnership should work with subresources
Ensure that we can force when applying to subresources (in particular status) Issue #2125
1 parent b2c5e38 commit abe8a6e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/client/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,11 @@ func (forceOwnership) ApplyToPatch(opts *PatchOptions) {
788788
opts.Force = &definitelyTrue
789789
}
790790

791+
func (forceOwnership) ApplyToSubResourcePatch(opts *SubResourcePatchOptions) {
792+
definitelyTrue := true
793+
opts.Force = &definitelyTrue
794+
}
795+
791796
// }}}
792797

793798
// {{{ DeleteAllOf Options

pkg/client/options_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,18 @@ var _ = Describe("FieldOwner", func() {
277277
Expect(o.FieldManager).To(Equal("foo"))
278278
})
279279
})
280+
281+
var _ = Describe("ForceOwnership", func() {
282+
It("Should apply to PatchOptions", func() {
283+
o := &client.PatchOptions{}
284+
t := client.ForceOwnership
285+
t.ApplyToPatch(o)
286+
Expect(o.Force).To(Equal(true))
287+
})
288+
It("Should apply to SubResourcePatchOptions", func() {
289+
o := &client.SubResourcePatchOptions{PatchOptions: client.PatchOptions{}}
290+
t := client.ForceOwnership
291+
t.ApplyToSubResourcePatch(o)
292+
Expect(o.Force).To(Equal(true))
293+
})
294+
})

0 commit comments

Comments
 (0)