From d4f7b29b048623bd5e42e53337ccb8448f74cf2d Mon Sep 17 00:00:00 2001 From: PatrickLaabs Date: Thu, 17 Jul 2025 15:11:55 +0200 Subject: [PATCH] chore: replacing timer ptr with ptr.To Kubernetes-commit: 2b13b87e609b83f453f7a160d9cae8a15c0e64f2 --- plugin/pkg/client/auth/exec/metrics_test.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/plugin/pkg/client/auth/exec/metrics_test.go b/plugin/pkg/client/auth/exec/metrics_test.go index 61360abd..bf588dcd 100644 --- a/plugin/pkg/client/auth/exec/metrics_test.go +++ b/plugin/pkg/client/auth/exec/metrics_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" "k8s.io/client-go/tools/clientcmd/api" "k8s.io/client-go/tools/metrics" + "k8s.io/utils/ptr" ) type mockExpiryGauge struct { @@ -35,10 +36,6 @@ func (m *mockExpiryGauge) Set(t *time.Time) { m.v = t } -func ptr(t time.Time) *time.Time { - return &t -} - func TestCertificateExpirationTracker(t *testing.T) { now := time.Now() mockMetric := &mockExpiryGauge{} @@ -60,25 +57,25 @@ func TestCertificateExpirationTracker(t *testing.T) { desc: "ttl for one authenticator", auth: firstAuthenticator, time: now.Add(time.Minute * 10), - want: ptr(now.Add(time.Minute * 10)), + want: ptr.To(now.Add(time.Minute * 10)), }, { desc: "second authenticator shorter ttl", auth: secondAuthenticator, time: now.Add(time.Minute * 5), - want: ptr(now.Add(time.Minute * 5)), + want: ptr.To(now.Add(time.Minute * 5)), }, { desc: "update shorter to be longer", auth: secondAuthenticator, time: now.Add(time.Minute * 15), - want: ptr(now.Add(time.Minute * 10)), + want: ptr.To(now.Add(time.Minute * 10)), }, { desc: "update shorter to be zero time", auth: firstAuthenticator, time: time.Time{}, - want: ptr(now.Add(time.Minute * 15)), + want: ptr.To(now.Add(time.Minute * 15)), }, { desc: "update last to be zero time records nil", @@ -194,8 +191,8 @@ func TestCallsMetric(t *testing.T) { callsMetricComparer := cmp.Comparer(func(a, b mockCallsMetric) bool { return a.exitCode == b.exitCode && a.errorType == b.errorType }) - actuallCallsMetrics := callsMetricCounter.calls - if diff := cmp.Diff(wantCallsMetrics, actuallCallsMetrics, callsMetricComparer); diff != "" { + actualCallsMetrics := callsMetricCounter.calls + if diff := cmp.Diff(wantCallsMetrics, actualCallsMetrics, callsMetricComparer); diff != "" { t.Fatalf("got unexpected metrics calls; -want, +got:\n%s", diff) } }