@@ -62,7 +62,7 @@ func (p returnRequestPolicy) Do(ctx context.Context, r pipeline.Request) (pipeli
6262 return resp , nil
6363}
6464
65- // hijack the SharedKeyCredentials signing code from azure-storage-blob-go
65+ // WithAuthorization hijack the SharedKeyCredentials signing code from azure-storage-blob-go
6666// https://github.com/Azure/go-autorest/issues/456
6767func (config * AZBlobConfig ) WithAuthorization () autorest.PrepareDecorator {
6868 return func (p autorest.Preparer ) autorest.Preparer {
@@ -97,7 +97,7 @@ type ADLv2Config struct {
9797
9898type AzureAuthorizerConfig struct {
9999 Log * LogHandle
100- TenantId string
100+ TenantID string
101101}
102102
103103var azbLog = GetLogger ("azblob" )
@@ -118,10 +118,10 @@ func tokenToAuthorizer(t *cli.Token) (autorest.Authorizer, error) {
118118 return nil , err
119119 }
120120
121- tenantId := u .Path
121+ tenantID := u .Path
122122 u .Path = ""
123123
124- oauth , err := adal .NewOAuthConfig (u .String (), tenantId )
124+ oauth , err := adal .NewOAuthConfig (u .String (), tenantID )
125125 if err != nil {
126126 return nil , err
127127 }
@@ -161,12 +161,12 @@ func msiToAuthorizer(mc auth.MSIConfig) (autorest.Authorizer, error) {
161161}
162162
163163func (c AzureAuthorizerConfig ) Authorizer () (autorest.Authorizer , error ) {
164- if c .TenantId == "" {
164+ if c .TenantID == "" {
165165 defaultSubscription , err := azureDefaultSubscription ()
166166 if err != nil {
167167 return nil , err
168168 }
169- c .TenantId = defaultSubscription .TenantID
169+ c .TenantID = defaultSubscription .TenantID
170170 }
171171
172172 env , err := auth .GetSettingsFromEnvironment ()
@@ -194,7 +194,7 @@ func (c AzureAuthorizerConfig) Authorizer() (autorest.Authorizer, error) {
194194 env .Values [auth .ActiveDirectoryEndpoint ] = env .Environment .ActiveDirectoryEndpoint
195195 }
196196 adEndpoint := strings .Trim (env .Values [auth .ActiveDirectoryEndpoint ], "/" ) +
197- "/" + c .TenantId
197+ "/" + c .TenantID
198198 c .Log .Debugf ("looking for access token for %v" , adEndpoint )
199199
200200 accessTokensPath , err := cli .AccessTokensPath ()
@@ -238,7 +238,7 @@ func azureDefaultSubscription() (*cli.Subscription, error) {
238238 }
239239 }
240240
241- return nil , fmt .Errorf ("Unable to find default azure subscription id" )
241+ return nil , fmt .Errorf ("unable to find default azure subscription id" )
242242}
243243
244244func azureAccountsClient (account string ) (azblob.AccountsClient , error ) {
@@ -253,7 +253,7 @@ func azureAccountsClient(account string) (azblob.AccountsClient, error) {
253253
254254 authorizer , err := AzureAuthorizerConfig {
255255 Log : azbLog ,
256- TenantId : defaultSubscription .TenantID ,
256+ TenantID : defaultSubscription .TenantID ,
257257 }.Authorizer ()
258258 if err != nil {
259259 return c , err
@@ -274,13 +274,13 @@ func azureFindAccount(client azblob.AccountsClient, account string) (*azblob.End
274274 // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/...
275275 parts := strings .SplitN (* acc .ID , "/" , 6 )
276276 if len (parts ) != 6 {
277- return nil , "" , fmt .Errorf ("Malformed account id: %v" , * acc .ID )
277+ return nil , "" , fmt .Errorf ("malformed account id: %v" , * acc .ID )
278278 }
279279 return acc .PrimaryEndpoints , parts [4 ], nil
280280 }
281281 }
282282
283- return nil , "" , fmt .Errorf ("Azure account not found: %v" , account )
283+ return nil , "" , fmt .Errorf ("azure account not found: %v" , account )
284284}
285285
286286func AzureBlobConfig (endpoint string , location string , storageType string ) (config AZBlobConfig , err error ) {
@@ -341,7 +341,7 @@ func AzureBlobConfig(endpoint string, location string, storageType string) (conf
341341 }
342342 // at this point I have to have the account
343343 if account == "" {
344- err = fmt .Errorf ("Missing account: configure via AZURE_STORAGE_ACCOUNT " +
344+ err = fmt .Errorf ("missing account: configure via AZURE_STORAGE_ACCOUNT " +
345345 "or %v/config" , configDir )
346346 return
347347 }
@@ -355,7 +355,7 @@ func AzureBlobConfig(endpoint string, location string, storageType string) (conf
355355 endpoints , resourceGroup , err = azureFindAccount (client , account )
356356 if err != nil {
357357 if key == "" {
358- err = fmt .Errorf ("Missing key: configure via AZURE_STORAGE_KEY " +
358+ err = fmt .Errorf ("missing key: configure via AZURE_STORAGE_KEY " +
359359 "or %v/config" , configDir )
360360 return
361361 }
@@ -372,7 +372,7 @@ func AzureBlobConfig(endpoint string, location string, storageType string) (conf
372372 var keysRes azblob.AccountListKeysResult
373373 keysRes , err = client .ListKeys (context .TODO (), resourceGroup , account , azblob .Kerb )
374374 if err != nil || len (* keysRes .Keys ) == 0 {
375- err = fmt .Errorf ("Missing key: configure via AZURE_STORAGE_KEY " +
375+ err = fmt .Errorf ("missing key: configure via AZURE_STORAGE_KEY " +
376376 "or %v/config" , configDir )
377377 return
378378 }
@@ -384,8 +384,10 @@ func AzureBlobConfig(endpoint string, location string, storageType string) (conf
384384 break
385385 }
386386 }
387- // if not just take the first one
388- key = * (* keysRes .Keys )[0 ].Value
387+ if key == "" {
388+ // if not just take the first one
389+ key = * (* keysRes .Keys )[0 ].Value
390+ }
389391 }
390392 } else {
391393 if key == "" {
0 commit comments