@@ -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
"sigs.k8s.io/cloud-provider-azure/pkg/retry"
43
44
44
45
type azureFileDataplaneClient struct {
45
46
accountName string
46
- accountKey string
47
47
* service.Client
48
48
}
49
49
@@ -71,7 +71,6 @@ func newAzureFileClient(accountName, accountKey, storageEndpointSuffix string, b
71
71
72
72
return & azureFileDataplaneClient {
73
73
accountName : accountName ,
74
- accountKey : accountKey ,
75
74
Client : fileClient ,
76
75
}, nil
77
76
}
@@ -80,15 +79,10 @@ func (f *azureFileDataplaneClient) CreateFileShare(ctx context.Context, shareOpt
80
79
if shareOptions == nil {
81
80
return fmt .Errorf ("shareOptions of account(%s) is nil" , f .accountName )
82
81
}
83
- shareClient := f .Client .NewShareClient (shareOptions .Name )
84
- _ , err := shareClient .Create (ctx , & share.CreateOptions {
82
+ _ , err := f .Client .NewShareClient (shareOptions .Name ).Create (ctx , & share.CreateOptions {
85
83
Quota : to .Ptr (int32 (shareOptions .RequestGiB )),
86
84
})
87
-
88
- if err != nil {
89
- return fmt .Errorf ("failed to create file share, err: %v" , err )
90
- }
91
- return nil
85
+ return err
92
86
}
93
87
94
88
// delete a file share
@@ -118,10 +112,9 @@ func (f *azureFileDataplaneClient) ResizeFileShare(ctx context.Context, shareNam
118
112
}
119
113
120
114
func (f * azureFileDataplaneClient ) GetFileShareQuota (ctx context.Context , name string ) (int , error ) {
121
- shareClient := f .Client .NewShareClient (name )
122
- shareProps , err := shareClient .GetProperties (ctx , nil )
115
+ shareProps , err := f .Client .NewShareClient (name ).GetProperties (ctx , nil )
123
116
if err != nil {
124
117
return - 1 , err
125
118
}
126
- return int (* shareProps .Quota ), nil
119
+ return int (ptr . Deref ( shareProps .Quota , 0 ) ), nil
127
120
}
0 commit comments