@@ -24,6 +24,7 @@ import (
24
24
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
25
25
26
26
"k8s.io/klog/v2"
27
+ "k8s.io/legacy-cloud-providers/azure/clients/fileclient"
27
28
)
28
29
29
30
const (
@@ -36,25 +37,32 @@ const (
36
37
37
38
// CreateFileShare creates a file share, using a matching storage account type, account kind, etc.
38
39
// storage account will be created if specified account is not found
39
- func (az * Cloud ) CreateFileShare (shareName , accountName , accountType , accountKind , resourceGroup , location string , protocol storage.EnabledProtocols , requestGiB int ) (string , string , error ) {
40
- if resourceGroup == "" {
41
- resourceGroup = az .resourceGroup
40
+ func (az * Cloud ) CreateFileShare (accountOptions * AccountOptions , shareOptions * fileclient.ShareOptions ) (string , string , error ) {
41
+ if accountOptions == nil {
42
+ return "" , "" , fmt .Errorf ("account options is nil" )
43
+ }
44
+ if shareOptions == nil {
45
+ return "" , "" , fmt .Errorf ("share options is nil" )
46
+ }
47
+ if accountOptions .ResourceGroup == "" {
48
+ accountOptions .ResourceGroup = az .resourceGroup
42
49
}
43
50
44
- enableHTTPSTrafficOnly : = true
45
- if protocol == storage .NFS {
46
- enableHTTPSTrafficOnly = false
51
+ accountOptions . EnableHTTPSTrafficOnly = true
52
+ if shareOptions . Protocol == storage .NFS {
53
+ accountOptions . EnableHTTPSTrafficOnly = false
47
54
}
48
- account , key , err := az .EnsureStorageAccount (accountName , accountType , accountKind , resourceGroup , location , fileShareAccountNamePrefix , enableHTTPSTrafficOnly )
55
+
56
+ accountName , accountKey , err := az .EnsureStorageAccount (accountOptions , fileShareAccountNamePrefix )
49
57
if err != nil {
50
- return "" , "" , fmt .Errorf ("could not get storage key for storage account %s: %v" , accountName , err )
58
+ return "" , "" , fmt .Errorf ("could not get storage key for storage account %s: %v" , accountOptions . Name , err )
51
59
}
52
60
53
- if err := az .createFileShare (resourceGroup , account , shareName , protocol , requestGiB ); err != nil {
54
- return "" , "" , fmt .Errorf ("failed to create share %s in account %s: %v" , shareName , account , err )
61
+ if err := az .createFileShare (accountOptions . ResourceGroup , accountName , shareOptions ); err != nil {
62
+ return "" , "" , fmt .Errorf ("failed to create share %s in account %s: %v" , shareOptions . Name , accountName , err )
55
63
}
56
- klog .V (4 ).Infof ("created share %s in account %s" , shareName , account )
57
- return account , key , nil
64
+ klog .V (4 ).Infof ("created share %s in account %s" , shareOptions . Name , accountOptions . Name )
65
+ return accountName , accountKey , nil
58
66
}
59
67
60
68
// DeleteFileShare deletes a file share using storage account name and key
0 commit comments