Skip to content

Commit e1f80b9

Browse files
committed
Client: Force ownership supports Apply
1 parent d20f30a commit e1f80b9

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

pkg/client/applyconfigurations.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type unstructuredApplyConfiguration struct {
2929
func (u *unstructuredApplyConfiguration) IsApplyConfiguration() {}
3030

3131
// ApplyConfigurationFromUnstructured creates a runtime.ApplyConfiguration from an *unstructured.Unstructured object.
32+
//
33+
// Do not use Unstructured objects here that were generated from API objects, as those
34+
// contain zero values.
3235
func ApplyConfigurationFromUnstructured(u *unstructured.Unstructured) runtime.ApplyConfiguration {
3336
return &unstructuredApplyConfiguration{Unstructured: u}
3437
}

pkg/client/options.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,15 @@ var ForceOwnership = forceOwnership{}
931931
type forceOwnership struct{}
932932

933933
func (forceOwnership) ApplyToPatch(opts *PatchOptions) {
934-
definitelyTrue := true
935-
opts.Force = &definitelyTrue
934+
opts.Force = ptr.To(true)
936935
}
937936

938937
func (forceOwnership) ApplyToSubResourcePatch(opts *SubResourcePatchOptions) {
939-
definitelyTrue := true
940-
opts.Force = &definitelyTrue
938+
opts.Force = ptr.To(true)
939+
}
940+
941+
func (forceOwnership) ApplyToApply(opts *ApplyOptions) {
942+
opts.Force = ptr.To(true)
941943
}
942944

943945
// }}}

pkg/client/options_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ var _ = Describe("ForceOwnership", func() {
330330
t.ApplyToSubResourcePatch(o)
331331
Expect(*o.Force).To(BeTrue())
332332
})
333+
It("Should apply to ApplyOptions", func() {
334+
o := &client.ApplyOptions{}
335+
t := client.ForceOwnership
336+
t.ApplyToApply(o)
337+
Expect(*o.Force).To(BeTrue())
338+
})
333339
})
334340

335341
var _ = Describe("HasLabels", func() {

0 commit comments

Comments
 (0)