Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: simplify SSA patch calls #393

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/csaupgrade"
"k8s.io/utils/clock"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -103,12 +102,7 @@ func (b *bundle) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result,
return ctrl.Result{}, utilerrors.NewAggregate([]error{resultErr, err})
}

if err := b.client.Status().Patch(ctx, con, patch, &client.SubResourcePatchOptions{
PatchOptions: client.PatchOptions{
FieldManager: fieldManager,
Force: ptr.To(true),
},
}); err != nil {
if err := b.client.Status().Patch(ctx, con, patch, client.FieldOwner(fieldManager), client.ForceOwnership); err != nil {
err = fmt.Errorf("failed to apply bundle status patch: %w", err)
return ctrl.Result{}, utilerrors.NewAggregate([]error{resultErr, err})
}
Expand Down
10 changes: 2 additions & 8 deletions pkg/bundle/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ func (b *bundle) patchConfigMapResource(ctx context.Context, applyConfig *coreap
return fmt.Errorf("failed to generate patch: %w", err)
}

err = b.client.Patch(ctx, configMap, patch, &client.PatchOptions{
FieldManager: fieldManager,
Force: ptr.To(true),
})
err = b.client.Patch(ctx, configMap, patch, client.FieldOwner(fieldManager), client.ForceOwnership)
if err != nil {
return err
}
Expand All @@ -396,10 +393,7 @@ func (b *bundle) patchSecretResource(ctx context.Context, applyConfig *coreapply
return fmt.Errorf("failed to generate patch: %w", err)
}

err = b.client.Patch(ctx, secret, patch, &client.PatchOptions{
FieldManager: fieldManager,
Force: ptr.To(true),
})
err = b.client.Patch(ctx, secret, patch, client.FieldOwner(fieldManager), client.ForceOwnership)
if err != nil {
return err
}
Expand Down