@@ -25,6 +25,7 @@ import (
25
25
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service"
26
26
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share"
27
27
"k8s.io/klog/v2"
28
+ "k8s.io/utils/ptr"
28
29
29
30
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/utils"
30
31
)
42
43
43
44
type azureFileDataplaneClient struct {
44
45
accountName string
45
- accountKey string
46
46
* service.Client
47
47
}
48
48
@@ -67,7 +67,6 @@ func newAzureFileClient(accountName, accountKey, storageEndpointSuffix string) (
67
67
68
68
return & azureFileDataplaneClient {
69
69
accountName : accountName ,
70
- accountKey : accountKey ,
71
70
Client : fileClient ,
72
71
}, nil
73
72
}
@@ -76,15 +75,10 @@ func (f *azureFileDataplaneClient) CreateFileShare(ctx context.Context, shareOpt
76
75
if shareOptions == nil {
77
76
return fmt .Errorf ("shareOptions of account(%s) is nil" , f .accountName )
78
77
}
79
- shareClient := f .Client .NewShareClient (shareOptions .Name )
80
- _ , err := shareClient .Create (ctx , & share.CreateOptions {
78
+ _ , err := f .Client .NewShareClient (shareOptions .Name ).Create (ctx , & share.CreateOptions {
81
79
Quota : to .Ptr (int32 (shareOptions .RequestGiB )),
82
80
})
83
-
84
- if err != nil {
85
- return fmt .Errorf ("failed to create file share, err: %v" , err )
86
- }
87
- return nil
81
+ return err
88
82
}
89
83
90
84
// delete a file share
@@ -114,10 +108,9 @@ func (f *azureFileDataplaneClient) ResizeFileShare(ctx context.Context, shareNam
114
108
}
115
109
116
110
func (f * azureFileDataplaneClient ) GetFileShareQuota (ctx context.Context , name string ) (int , error ) {
117
- shareClient := f .Client .NewShareClient (name )
118
- shareProps , err := shareClient .GetProperties (ctx , nil )
111
+ shareProps , err := f .Client .NewShareClient (name ).GetProperties (ctx , nil )
119
112
if err != nil {
120
113
return - 1 , err
121
114
}
122
- return int (* shareProps .Quota ), nil
115
+ return int (ptr . Deref ( shareProps .Quota , 0 ) ), nil
123
116
}
0 commit comments