@@ -477,13 +477,11 @@ func (d *Driver) getFileShareQuota(ctx context.Context, accountOptions *storage.
477
477
if err != nil {
478
478
return - 1 , err
479
479
}
480
- fileClient , err = newAzureFileClient (accountName , accountKey , d .getStorageEndPointSuffix ())
481
- if err != nil {
480
+ if fileClient , err = newAzureFileClient (accountName , accountKey , d .getStorageEndPointSuffix ()); err != nil {
482
481
return - 1 , err
483
482
}
484
483
} else {
485
- fileClient , err = newAzureFileMgmtClient (d .cloud .ComputeClientFactory , accountOptions )
486
- if err != nil {
484
+ if fileClient , err = newAzureFileMgmtClient (d .cloud , accountOptions ); err != nil {
487
485
return - 1 , err
488
486
}
489
487
}
@@ -950,7 +948,7 @@ func (d *Driver) CreateFileShare(ctx context.Context, accountOptions *storage.Ac
950
948
return true , err
951
949
}
952
950
} else {
953
- if fileClient , err = newAzureFileMgmtClient (d .cloud . ComputeClientFactory , accountOptions ); err != nil {
951
+ if fileClient , err = newAzureFileMgmtClient (d .cloud , accountOptions ); err != nil {
954
952
return true , err
955
953
}
956
954
}
@@ -981,10 +979,9 @@ func (d *Driver) DeleteFileShare(ctx context.Context, subsID, resourceGroup, acc
981
979
}
982
980
err = fileClient .DeleteFileShare (ctx , shareName )
983
981
} else {
984
- var fileClient fileshareclient.Interface
985
- fileClient , err = d .cloud .ComputeClientFactory .GetFileShareClientForSub (subsID )
986
- if err != nil {
987
- return true , err
982
+ fileClient , errGetClient := d .getFileShareClientForSub (subsID )
983
+ if errGetClient != nil {
984
+ return true , errGetClient
988
985
}
989
986
err = fileClient .Delete (ctx , resourceGroup , accountName , shareName , nil )
990
987
}
@@ -1027,7 +1024,7 @@ func (d *Driver) ResizeFileShare(ctx context.Context, subsID, resourceGroup, acc
1027
1024
}
1028
1025
err = fileClient .ResizeFileShare (ctx , shareName , sizeGiB )
1029
1026
} else {
1030
- fileClient , err := d .cloud . ComputeClientFactory . GetFileShareClientForSub (subsID )
1027
+ fileClient , err := d .getFileShareClientForSub (subsID )
1031
1028
if err != nil {
1032
1029
return true , err
1033
1030
}
@@ -1092,7 +1089,7 @@ func (d *Driver) copyFileShare(ctx context.Context, req *csi.CreateVolumeRequest
1092
1089
1093
1090
// GetTotalAccountQuota returns the total quota in GB of all file shares in the storage account and the number of file shares
1094
1091
func (d * Driver ) GetTotalAccountQuota (ctx context.Context , subsID , resourceGroup , accountName string ) (int32 , int32 , error ) {
1095
- fileClient , err := d .cloud . ComputeClientFactory . GetFileShareClientForSub (subsID )
1092
+ fileClient , err := d .getFileShareClientForSub (subsID )
1096
1093
if err != nil {
1097
1094
return - 1 , - 1 , err
1098
1095
}
@@ -1111,7 +1108,7 @@ func (d *Driver) GetTotalAccountQuota(ctx context.Context, subsID, resourceGroup
1111
1108
1112
1109
// RemoveStorageAccountTag remove tag from storage account
1113
1110
func (d * Driver ) RemoveStorageAccountTag (ctx context.Context , subsID , resourceGroup , account , key string ) error {
1114
- if d .cloud == nil || d . cloud . ComputeClientFactory . GetAccountClient () == nil {
1111
+ if d .cloud == nil {
1115
1112
return fmt .Errorf ("cloud or StorageAccountClient is nil" )
1116
1113
}
1117
1114
// search in cache first
@@ -1275,3 +1272,10 @@ func (d *Driver) getStorageEndPointSuffix() string {
1275
1272
}
1276
1273
return d .cloud .Environment .StorageEndpointSuffix
1277
1274
}
1275
+
1276
+ func (d * Driver ) getFileShareClientForSub (subscriptionID string ) (fileshareclient.Interface , error ) {
1277
+ if d .cloud == nil || d .cloud .ComputeClientFactory == nil {
1278
+ return nil , fmt .Errorf ("cloud provider is not initialized" )
1279
+ }
1280
+ return d .cloud .ComputeClientFactory .GetFileShareClientForSub (subscriptionID )
1281
+ }
0 commit comments