Skip to content

Commit

Permalink
ForceOwnership should work with subresources
Browse files Browse the repository at this point in the history
Ensure that we can force when applying to subresources (in particular status)

Issue kubernetes-sigs#2125
  • Loading branch information
justinsb authored and k8s-infra-cherrypick-robot committed Mar 31, 2023
1 parent cd65cb2 commit 5998450
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ func (forceOwnership) ApplyToPatch(opts *PatchOptions) {
opts.Force = &definitelyTrue
}

func (forceOwnership) ApplyToSubResourcePatch(opts *SubResourcePatchOptions) {
definitelyTrue := true
opts.Force = &definitelyTrue
}

// }}}

// {{{ DeleteAllOf Options
Expand Down
15 changes: 15 additions & 0 deletions pkg/client/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,18 @@ var _ = Describe("FieldOwner", func() {
Expect(o.FieldManager).To(Equal("foo"))
})
})

var _ = Describe("ForceOwnership", func() {
It("Should apply to PatchOptions", func() {
o := &client.PatchOptions{}
t := client.ForceOwnership
t.ApplyToPatch(o)
Expect(*o.Force).To(Equal(true))
})
It("Should apply to SubResourcePatchOptions", func() {
o := &client.SubResourcePatchOptions{PatchOptions: client.PatchOptions{}}
t := client.ForceOwnership
t.ApplyToSubResourcePatch(o)
Expect(*o.Force).To(Equal(true))
})
})

0 comments on commit 5998450

Please sign in to comment.