Skip to content

Commit

Permalink
Merge pull request #393 from erikgb/better-ssa
Browse files Browse the repository at this point in the history
refactor: simplify SSA patch calls
  • Loading branch information
cert-manager-prow[bot] authored Jul 19, 2024
2 parents fb6516a + 826ac78 commit 825c6f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
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

0 comments on commit 825c6f6

Please # to comment.