Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit fe7ba81

Browse files
committed
refactor: use ptr.To instead of pointer.String
Signed-off-by: Chris Privitere <[email protected]>
1 parent 924d055 commit fe7ba81

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
k8s.io/client-go v0.26.1
1414
k8s.io/component-base v0.26.1
1515
k8s.io/klog/v2 v2.80.1
16-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
16+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
1717
sigs.k8s.io/cluster-api v1.4.6
1818
sigs.k8s.io/controller-runtime v0.14.6
1919
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,8 @@ k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
768768
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
769769
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E=
770770
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
771-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y=
772-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
771+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
772+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
773773
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
774774
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
775775
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

pkg/cloud/packet/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal
113113
stringWriter := &strings.Builder{}
114114
userData := string(userDataRaw)
115115
userDataValues := map[string]interface{}{
116-
"kubernetesVersion": pointer.StringPtrDerefOr(req.MachineScope.Machine.Spec.Version, ""),
116+
"kubernetesVersion": ptr.Deref(req.MachineScope.Machine.Spec.Version, ""),
117117
}
118118

119119
tags := make([]string, 0, len(packetMachineSpec.Tags)+len(req.ExtraTags))

pkg/cloud/packet/scope/machine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
apierrors "k8s.io/apimachinery/pkg/api/errors"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/types"
31-
"k8s.io/utils/pointer"
31+
"k8s.io/utils/ptr"
3232
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3333
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
3434
"sigs.k8s.io/cluster-api/controllers/noderefutil"
@@ -161,7 +161,7 @@ func (m *MachineScope) GetProviderID() string {
161161
// SetProviderID sets the DOMachine providerID in spec from device id.
162162
func (m *MachineScope) SetProviderID(deviceID string) {
163163
pid := fmt.Sprintf("%s://%s", m.providerIDPrefix, deviceID)
164-
m.PacketMachine.Spec.ProviderID = pointer.StringPtr(pid)
164+
m.PacketMachine.Spec.ProviderID = ptr.To(pid)
165165
}
166166

167167
// GetInstanceID returns the DOMachine droplet instance id by parsing Spec.ProviderID.
@@ -195,7 +195,7 @@ func (m *MachineScope) SetNotReady() {
195195

196196
// SetFailureMessage sets the PacketMachine status error message.
197197
func (m *MachineScope) SetFailureMessage(v error) {
198-
m.PacketMachine.Status.FailureMessage = pointer.StringPtr(v.Error())
198+
m.PacketMachine.Status.FailureMessage = ptr.To(v.Error())
199199
}
200200

201201
// SetFailureReason sets the PacketMachine status error reason.
@@ -411,7 +411,7 @@ func hasWorkloadDeployment(ctx context.Context, workloadClient client.Client, na
411411
}
412412

413413
func providerIDPrefixFromPacketMachine(packetMachine *infrav1.PacketMachine) string {
414-
preexistingProviderID := pointer.StringPtrDerefOr(packetMachine.Spec.ProviderID, "")
414+
preexistingProviderID := ptr.Deref(packetMachine.Spec.ProviderID, "")
415415
if preexistingProviderID != "" {
416416
if parsed, err := noderefutil.NewProviderID(preexistingProviderID); err == nil {
417417
return parsed.CloudProvider()

pkg/cloud/packet/scope/machine_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/apimachinery/pkg/runtime"
3030
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
31-
"k8s.io/utils/pointer"
31+
"k8s.io/utils/ptr"
3232
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3333
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
3434
"sigs.k8s.io/cluster-api/util"
@@ -120,7 +120,7 @@ func TestNewMachineScopeExistingProviderID(t *testing.T) {
120120
Name: util.RandomString(generatedNameLength),
121121
},
122122
Spec: infrav1.PacketMachineSpec{
123-
ProviderID: pointer.StringPtr(initialProviderID),
123+
ProviderID: ptr.To(initialProviderID),
124124
},
125125
}
126126

test/e2e/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
k8s.io/api v0.26.1
1818
k8s.io/apimachinery v0.26.1
1919
k8s.io/client-go v0.26.1
20-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
20+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
2121
sigs.k8s.io/cluster-api v1.4.6
2222
sigs.k8s.io/cluster-api-provider-packet v0.0.0-00010101000000-000000000000
2323
sigs.k8s.io/cluster-api/test v1.4.6

test/e2e/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,8 @@ k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
925925
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
926926
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E=
927927
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
928-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y=
929-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
928+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
929+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
930930
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
931931
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
932932
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

0 commit comments

Comments
 (0)