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 #2125
  • Loading branch information
justinsb committed Mar 31, 2023
1 parent b2c5e38 commit abe8a6e
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
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
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 abe8a6e

Please sign in to comment.