@@ -30,15 +30,15 @@ type accountWithLocation struct {
30
30
}
31
31
32
32
// getStorageAccounts gets name, type, location of all storage accounts in a resource group which matches matchingAccountType, matchingLocation
33
- func (az * Cloud ) getStorageAccounts (matchingAccountType , matchingLocation string ) ([]accountWithLocation , error ) {
33
+ func (az * Cloud ) getStorageAccounts (matchingAccountType , resourceGroup , matchingLocation string ) ([]accountWithLocation , error ) {
34
34
ctx , cancel := getContextWithCancel ()
35
35
defer cancel ()
36
- result , err := az .StorageAccountClient .ListByResourceGroup (ctx , az . ResourceGroup )
36
+ result , err := az .StorageAccountClient .ListByResourceGroup (ctx , resourceGroup )
37
37
if err != nil {
38
38
return nil , err
39
39
}
40
40
if result .Value == nil {
41
- return nil , fmt .Errorf ("unexpected error when listing storage accounts from resource group %s" , az . ResourceGroup )
41
+ return nil , fmt .Errorf ("unexpected error when listing storage accounts from resource group %s" , resourceGroup )
42
42
}
43
43
44
44
accounts := []accountWithLocation {}
@@ -61,11 +61,11 @@ func (az *Cloud) getStorageAccounts(matchingAccountType, matchingLocation string
61
61
}
62
62
63
63
// getStorageAccesskey gets the storage account access key
64
- func (az * Cloud ) getStorageAccesskey (account string ) (string , error ) {
64
+ func (az * Cloud ) getStorageAccesskey (account , resourceGroup string ) (string , error ) {
65
65
ctx , cancel := getContextWithCancel ()
66
66
defer cancel ()
67
67
68
- result , err := az .StorageAccountClient .ListKeys (ctx , az . ResourceGroup , account )
68
+ result , err := az .StorageAccountClient .ListKeys (ctx , resourceGroup , account )
69
69
if err != nil {
70
70
return "" , err
71
71
}
@@ -86,10 +86,10 @@ func (az *Cloud) getStorageAccesskey(account string) (string, error) {
86
86
}
87
87
88
88
// ensureStorageAccount search storage account, create one storage account(with genAccountNamePrefix) if not found, return accountName, accountKey
89
- func (az * Cloud ) ensureStorageAccount (accountName , accountType , location , genAccountNamePrefix string ) (string , string , error ) {
89
+ func (az * Cloud ) ensureStorageAccount (accountName , accountType , resourceGroup , location , genAccountNamePrefix string ) (string , string , error ) {
90
90
if len (accountName ) == 0 {
91
91
// find a storage account that matches accountType
92
- accounts , err := az .getStorageAccounts (accountType , location )
92
+ accounts , err := az .getStorageAccounts (accountType , resourceGroup , location )
93
93
if err != nil {
94
94
return "" , "" , fmt .Errorf ("could not list storage accounts for account type %s: %v" , accountType , err )
95
95
}
@@ -110,7 +110,7 @@ func (az *Cloud) ensureStorageAccount(accountName, accountType, location, genAcc
110
110
}
111
111
112
112
glog .V (2 ).Infof ("azure - no matching account found, begin to create a new account %s in resource group %s, location: %s, accountType: %s" ,
113
- accountName , az . ResourceGroup , location , accountType )
113
+ accountName , resourceGroup , location , accountType )
114
114
cp := storage.AccountCreateParameters {
115
115
Sku : & storage.Sku {Name : storage .SkuName (accountType )},
116
116
// switch to use StorageV2 as it's recommended according to https://docs.microsoft.com/en-us/azure/storage/common/storage-account-options
@@ -121,15 +121,15 @@ func (az *Cloud) ensureStorageAccount(accountName, accountType, location, genAcc
121
121
122
122
ctx , cancel := getContextWithCancel ()
123
123
defer cancel ()
124
- _ , err := az .StorageAccountClient .Create (ctx , az . ResourceGroup , accountName , cp )
124
+ _ , err := az .StorageAccountClient .Create (ctx , resourceGroup , accountName , cp )
125
125
if err != nil {
126
126
return "" , "" , fmt .Errorf (fmt .Sprintf ("Failed to create storage account %s, error: %s" , accountName , err ))
127
127
}
128
128
}
129
129
}
130
130
131
131
// find the access key with this account
132
- accountKey , err := az .getStorageAccesskey (accountName )
132
+ accountKey , err := az .getStorageAccesskey (accountName , resourceGroup )
133
133
if err != nil {
134
134
return "" , "" , fmt .Errorf ("could not get storage key for storage account %s: %v" , accountName , err )
135
135
}
0 commit comments