Skip to content

Commit 6046abf

Browse files
committed
chore: Replace deprecated k8s.io/utils/pointer with k8s.io/utils/ptr
1 parent 6254136 commit 6046abf

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

pkg/blob/azure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"golang.org/x/net/context"
3030
"k8s.io/client-go/kubernetes"
3131
"k8s.io/klog/v2"
32-
"k8s.io/utils/pointer"
32+
"k8s.io/utils/ptr"
3333
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader"
3434
azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
3535
azure "sigs.k8s.io/cloud-provider-azure/pkg/provider"
@@ -263,7 +263,7 @@ func (d *Driver) updateSubnetServiceEndpoints(ctx context.Context, vnetResourceG
263263
}
264264
serviceEndpoints := *subnet.SubnetPropertiesFormat.ServiceEndpoints
265265
for _, v := range serviceEndpoints {
266-
if strings.HasPrefix(pointer.StringDeref(v.Service, ""), storageService) {
266+
if strings.HasPrefix(ptr.Deref(v.Service, ""), storageService) {
267267
storageServiceExists = true
268268
klog.V(4).Infof("serviceEndpoint(%s) is already in subnet(%s)", storageService, sn)
269269
break

pkg/blob/azure_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/stretchr/testify/assert"
3333
"go.uber.org/mock/gomock"
3434
"k8s.io/client-go/kubernetes"
35-
"k8s.io/utils/pointer"
35+
"k8s.io/utils/ptr"
3636

3737
"sigs.k8s.io/blob-csi-driver/pkg/util"
3838
"sigs.k8s.io/cloud-provider-azure/pkg/azureclients/subnetclient/mocksubnetclient"
@@ -344,7 +344,7 @@ func TestUpdateSubnetServiceEndpoints(t *testing.T) {
344344
testFunc: func(t *testing.T) {
345345
fakeSubnet := network.Subnet{
346346
SubnetPropertiesFormat: &network.SubnetPropertiesFormat{},
347-
Name: pointer.String("subnetName"),
347+
Name: ptr.To("subnetName"),
348348
}
349349

350350
mockSubnetClient.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fakeSubnet, nil).Times(1)
@@ -361,7 +361,7 @@ func TestUpdateSubnetServiceEndpoints(t *testing.T) {
361361
SubnetPropertiesFormat: &network.SubnetPropertiesFormat{
362362
ServiceEndpoints: &[]network.ServiceEndpointPropertiesFormat{},
363363
},
364-
Name: pointer.String("subnetName"),
364+
Name: ptr.To("subnetName"),
365365
}
366366

367367
mockSubnetClient.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fakeSubnet, nil).AnyTimes()
@@ -383,7 +383,7 @@ func TestUpdateSubnetServiceEndpoints(t *testing.T) {
383383
},
384384
},
385385
},
386-
Name: pointer.String("subnetName"),
386+
Name: ptr.To("subnetName"),
387387
}
388388

389389
mockSubnetClient.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(fakeSubnet, nil).AnyTimes()

pkg/blob/controllerserver.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
"k8s.io/apimachinery/pkg/util/wait"
4242
"k8s.io/klog/v2"
43-
"k8s.io/utils/pointer"
43+
"k8s.io/utils/ptr"
4444

4545
"sigs.k8s.io/blob-csi-driver/pkg/util"
4646
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/blobcontainerclient"
@@ -99,7 +99,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
9999
var vnetResourceIDs []string
100100
var err error
101101
// set allowBlobPublicAccess as false by default
102-
allowBlobPublicAccess := pointer.Bool(false)
102+
allowBlobPublicAccess := ptr.To(false)
103103

104104
containerNameReplaceMap := map[string]string{}
105105

@@ -138,7 +138,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
138138
secretNamespace = v
139139
case isHnsEnabledField:
140140
if strings.EqualFold(v, trueValue) {
141-
isHnsEnabled = pointer.Bool(true)
141+
isHnsEnabled = ptr.To(true)
142142
}
143143
case softDeleteBlobsField:
144144
days, err := parseDays(v)
@@ -153,7 +153,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
153153
}
154154
softDeleteContainers = days
155155
case enableBlobVersioningField:
156-
enableBlobVersioning = pointer.Bool(strings.EqualFold(v, trueValue))
156+
enableBlobVersioning = ptr.To(strings.EqualFold(v, trueValue))
157157
case storeAccountKeyField:
158158
if strings.EqualFold(v, falseValue) {
159159
storeAccountKey = false
@@ -164,17 +164,17 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
164164
}
165165
case allowBlobPublicAccessField:
166166
if strings.EqualFold(v, trueValue) {
167-
allowBlobPublicAccess = pointer.Bool(true)
167+
allowBlobPublicAccess = ptr.To(true)
168168
}
169169
case allowSharedKeyAccessField:
170170
var boolValue bool
171171
if boolValue, err = strconv.ParseBool(v); err != nil {
172172
return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in volume context", allowSharedKeyAccessField, v)
173173
}
174-
allowSharedKeyAccess = pointer.Bool(boolValue)
174+
allowSharedKeyAccess = ptr.To(boolValue)
175175
case requireInfraEncryptionField:
176176
if strings.EqualFold(v, trueValue) {
177-
requireInfraEncryption = pointer.Bool(true)
177+
requireInfraEncryption = ptr.To(true)
178178
}
179179
case pvcNamespaceKey:
180180
pvcNamespace = v
@@ -221,8 +221,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
221221
}
222222
}
223223

224-
if pointer.BoolDeref(enableBlobVersioning, false) {
225-
if isNFSProtocol(protocol) || pointer.BoolDeref(isHnsEnabled, false) {
224+
if ptr.Deref(enableBlobVersioning, false) {
225+
if isNFSProtocol(protocol) || ptr.Deref(isHnsEnabled, false) {
226226
return nil, status.Errorf(codes.InvalidArgument, "enableBlobVersioning is not supported for NFS protocol or HNS enabled account")
227227
}
228228
}
@@ -269,15 +269,15 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
269269
if strings.Contains(subnetName, ",") {
270270
return nil, status.Errorf(codes.InvalidArgument, "subnetName(%s) can only contain one subnet for private endpoint", subnetName)
271271
}
272-
createPrivateEndpoint = pointer.BoolPtr(true)
272+
createPrivateEndpoint = ptr.To(true)
273273
}
274274
accountKind := string(armstorage.KindStorageV2)
275275
if isNFSProtocol(protocol) {
276-
isHnsEnabled = pointer.Bool(true)
277-
enableNfsV3 = pointer.Bool(true)
276+
isHnsEnabled = ptr.To(true)
277+
enableNfsV3 = ptr.To(true)
278278
// NFS protocol does not need account key
279279
storeAccountKey = false
280-
if !pointer.BoolDeref(createPrivateEndpoint, false) {
280+
if !ptr.Deref(createPrivateEndpoint, false) {
281281
// set VirtualNetworkResourceIDs for storage account firewall setting
282282
var err error
283283
if vnetResourceIDs, err = d.updateSubnetServiceEndpoints(ctx, vnetResourceGroup, vnetName, subnetName); err != nil {
@@ -305,7 +305,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
305305
storageEndpointSuffix = d.getStorageEndPointSuffix()
306306
}
307307

308-
if storeAccountKey && !pointer.BoolDeref(allowSharedKeyAccess, true) {
308+
if storeAccountKey && !ptr.Deref(allowSharedKeyAccess, true) {
309309
return nil, status.Errorf(codes.InvalidArgument, "storeAccountKey is not supported for account with shared access key disabled")
310310
}
311311

@@ -382,7 +382,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
382382
if v, ok := d.volMap.Load(volName); ok {
383383
accountName = v.(string)
384384
} else {
385-
lockKey := fmt.Sprintf("%s%s%s%s%s%v", storageAccountType, accountKind, resourceGroup, location, protocol, pointer.BoolDeref(createPrivateEndpoint, false))
385+
lockKey := fmt.Sprintf("%s%s%s%s%s%v", storageAccountType, accountKind, resourceGroup, location, protocol, ptr.Deref(createPrivateEndpoint, false))
386386
// search in cache first
387387
cache, err := d.accountSearchCache.Get(lockKey, azcache.CacheReadTypeDefault)
388388
if err != nil {
@@ -411,7 +411,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
411411
}
412412
}
413413

414-
if pointer.BoolDeref(createPrivateEndpoint, false) && isNFSProtocol(protocol) {
414+
if ptr.Deref(createPrivateEndpoint, false) && isNFSProtocol(protocol) {
415415
// As for blobfuse/blobfuse2, serverName, i.e.,AZURE_STORAGE_BLOB_ENDPOINT env variable can't include
416416
// "privatelink", issue: https://github.com/Azure/azure-storage-fuse/issues/1014
417417
//

test/e2e/testsuites/testsuites.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import (
4848
e2epv "k8s.io/kubernetes/test/e2e/framework/pv"
4949
testutil "k8s.io/kubernetes/test/utils"
5050
imageutils "k8s.io/kubernetes/test/utils/image"
51-
"k8s.io/utils/pointer"
51+
"k8s.io/utils/ptr"
5252
)
5353

5454
const (
@@ -452,7 +452,7 @@ func NewTestPod(c clientset.Interface, ns *v1.Namespace, command string) *TestPo
452452
},
453453
RestartPolicy: v1.RestartPolicyNever,
454454
Volumes: make([]v1.Volume, 0),
455-
AutomountServiceAccountToken: pointer.Bool(false),
455+
AutomountServiceAccountToken: ptr.To(false),
456456
},
457457
},
458458
}
@@ -561,7 +561,7 @@ func (t *TestPod) SetupInlineVolume(name, mountPath, secretName, containerName s
561561
"containerName": containerName,
562562
"mountOptions": "-o allow_other --file-cache-timeout-in-seconds=240",
563563
},
564-
ReadOnly: pointer.Bool(readOnly),
564+
ReadOnly: ptr.To(readOnly),
565565
},
566566
},
567567
}

test/utils/azure/authorization_helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"k8s.io/utils/pointer"
23+
"k8s.io/utils/ptr"
2424
"sigs.k8s.io/blob-csi-driver/test/utils/credentials"
2525

2626
"github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2020-04-01-preview/authorization"
@@ -65,8 +65,8 @@ func (a *AuthorizationClient) AssignRole(ctx context.Context, resourceID, princi
6565
uuid.NewV1().String(),
6666
authorization.RoleAssignmentCreateParameters{
6767
RoleAssignmentProperties: &authorization.RoleAssignmentProperties{
68-
PrincipalID: pointer.String(principalID),
69-
RoleDefinitionID: pointer.String(roleDefID),
68+
PrincipalID: ptr.To(principalID),
69+
RoleDefinitionID: ptr.To(roleDefID),
7070
},
7171
})
7272
}

0 commit comments

Comments
 (0)