Skip to content

Commit 72f4035

Browse files
committed
use k8s.io/utils/ptr
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 1b4736c commit 72f4035

File tree

8 files changed

+15
-46
lines changed

8 files changed

+15
-46
lines changed

controllers/certificaterequest_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3535
"k8s.io/client-go/tools/record"
3636
"k8s.io/utils/clock"
37-
"k8s.io/utils/pointer"
37+
"k8s.io/utils/ptr"
3838
ctrl "sigs.k8s.io/controller-runtime"
3939
"sigs.k8s.io/controller-runtime/pkg/builder"
4040
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -98,7 +98,7 @@ func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.R
9898
if err := r.Client.Status().Patch(ctx, &cr, patch, &client.SubResourcePatchOptions{
9999
PatchOptions: client.PatchOptions{
100100
FieldManager: r.FieldOwner,
101-
Force: pointer.Bool(true),
101+
Force: ptr.To(true),
102102
},
103103
}); err != nil {
104104
if err := client.IgnoreNotFound(err); err != nil {

controllers/certificaterequest_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/apimachinery/pkg/types"
3535
"k8s.io/client-go/tools/record"
3636
clocktesting "k8s.io/utils/clock/testing"
37+
"k8s.io/utils/ptr"
3738
"sigs.k8s.io/controller-runtime/pkg/client"
3839
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3940
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -43,7 +44,6 @@ import (
4344
"github.com/cert-manager/issuer-lib/controllers/signer"
4445
"github.com/cert-manager/issuer-lib/internal/kubeutil"
4546
"github.com/cert-manager/issuer-lib/internal/tests/errormatch"
46-
"github.com/cert-manager/issuer-lib/internal/tests/ptr"
4747
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/api"
4848
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/testutil"
4949
)
@@ -976,7 +976,7 @@ func TestCertificateRequestReconcilerReconcile(t *testing.T) {
976976

977977
assert.Equal(t, tc.expectedResult, res)
978978
assert.Equal(t, tc.expectedStatusPatch, crsPatch)
979-
ptr.Default(tc.validateError, *errormatch.NoError())(t, err)
979+
ptr.Deref(tc.validateError, *errormatch.NoError())(t, err)
980980

981981
allEvents := chanToSlice(fakeRecorder.Events)
982982
if len(tc.expectedEvents) == 0 {

controllers/certificatesigningrequest_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3737
"k8s.io/client-go/tools/record"
3838
"k8s.io/utils/clock"
39-
"k8s.io/utils/pointer"
39+
"k8s.io/utils/ptr"
4040
ctrl "sigs.k8s.io/controller-runtime"
4141
"sigs.k8s.io/controller-runtime/pkg/builder"
4242
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -93,7 +93,7 @@ func (r *CertificateSigningRequestReconciler) Reconcile(ctx context.Context, req
9393
if err := r.Client.Status().Patch(ctx, &cr, patch, &client.SubResourcePatchOptions{
9494
PatchOptions: client.PatchOptions{
9595
FieldManager: r.FieldOwner,
96-
Force: pointer.Bool(true),
96+
Force: ptr.To(true),
9797
},
9898
}); err != nil {
9999
if err := client.IgnoreNotFound(err); err != nil {

controllers/certificatesigningrequest_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"k8s.io/apimachinery/pkg/types"
3737
"k8s.io/client-go/tools/record"
3838
clocktesting "k8s.io/utils/clock/testing"
39+
"k8s.io/utils/ptr"
3940
"sigs.k8s.io/controller-runtime/pkg/client"
4041
"sigs.k8s.io/controller-runtime/pkg/client/fake"
4142
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -45,7 +46,6 @@ import (
4546
"github.com/cert-manager/issuer-lib/controllers/signer"
4647
"github.com/cert-manager/issuer-lib/internal/kubeutil"
4748
"github.com/cert-manager/issuer-lib/internal/tests/errormatch"
48-
"github.com/cert-manager/issuer-lib/internal/tests/ptr"
4949
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/api"
5050
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/testutil"
5151
)
@@ -809,7 +809,7 @@ func TestCertificateSigningRequestReconcilerReconcile(t *testing.T) {
809809

810810
assert.Equal(t, tc.expectedResult, res)
811811
assert.Equal(t, tc.expectedStatusPatch, crsPatch)
812-
ptr.Default(tc.validateError, *errormatch.NoError())(t, err)
812+
ptr.Deref(tc.validateError, *errormatch.NoError())(t, err)
813813

814814
allEvents := chanToSlice(fakeRecorder.Events)
815815
if len(tc.expectedEvents) == 0 {
@@ -937,7 +937,7 @@ func TestCertificateSigningRequestMatchIssuerType(t *testing.T) {
937937

938938
assert.Equal(t, tc.expectedIssuerType, issuerType)
939939
assert.Equal(t, tc.expectedIssuerName, issuerName)
940-
if !ptr.Default(tc.expectedError, *errormatch.NoError())(t, err) {
940+
if !ptr.Deref(tc.expectedError, *errormatch.NoError())(t, err) {
941941
t.Fail()
942942
}
943943
})

controllers/issuer_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
utilerrors "k8s.io/apimachinery/pkg/util/errors"
3131
"k8s.io/client-go/tools/record"
3232
"k8s.io/utils/clock"
33-
"k8s.io/utils/pointer"
33+
"k8s.io/utils/ptr"
3434
ctrl "sigs.k8s.io/controller-runtime"
3535
"sigs.k8s.io/controller-runtime/pkg/builder"
3636
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -85,7 +85,7 @@ func (r *IssuerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
8585
if err := r.Client.Status().Patch(ctx, cr, patch, &client.SubResourcePatchOptions{
8686
PatchOptions: client.PatchOptions{
8787
FieldManager: r.FieldOwner,
88-
Force: pointer.Bool(true),
88+
Force: ptr.To(true),
8989
},
9090
}); err != nil {
9191
if err := client.IgnoreNotFound(err); err != nil {

controllers/issuer_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/apimachinery/pkg/types"
3535
"k8s.io/client-go/tools/record"
3636
clocktesting "k8s.io/utils/clock/testing"
37+
"k8s.io/utils/ptr"
3738
"sigs.k8s.io/controller-runtime/pkg/client"
3839
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3940
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -42,7 +43,6 @@ import (
4243
"github.com/cert-manager/issuer-lib/api/v1alpha1"
4344
"github.com/cert-manager/issuer-lib/controllers/signer"
4445
"github.com/cert-manager/issuer-lib/internal/tests/errormatch"
45-
"github.com/cert-manager/issuer-lib/internal/tests/ptr"
4646
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/api"
4747
"github.com/cert-manager/issuer-lib/internal/testsetups/simple/testutil"
4848
)
@@ -421,7 +421,7 @@ func TestSimpleIssuerReconcilerReconcile(t *testing.T) {
421421

422422
assert.Equal(t, tc.expectedResult, res)
423423
assert.Equal(t, tc.expectedStatusPatch, crsPatch)
424-
ptr.Default(tc.validateError, *errormatch.NoError())(t, err)
424+
ptr.Deref(tc.validateError, *errormatch.NoError())(t, err)
425425

426426
allEvents := chanToSlice(fakeRecorder.Events)
427427
if len(tc.expectedEvents) == 0 {

internal/tests/errormatch/error_match.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import (
2020
"testing"
2121

2222
"github.com/stretchr/testify/assert"
23-
24-
"github.com/cert-manager/issuer-lib/internal/tests/ptr"
23+
"k8s.io/utils/ptr"
2524
)
2625

2726
type Matcher func(t testing.TB, err error) bool
2827

2928
func newMatcherPtr(matcher Matcher) *Matcher {
30-
return ptr.New(matcher)
29+
return ptr.To(matcher)
3130
}
3231

3332
func NoError() *Matcher {

internal/tests/ptr/ptr.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)