@@ -301,38 +301,36 @@ func (d *driver) storageAccountsClient(cfg *Azure, environment autorestazure.Env
301
301
storageAccountsClient .RetryAttempts = 1
302
302
_ = storageAccountsClient .AddToUserAgent (defaults .UserAgent )
303
303
304
- if d .authorizer != nil {
304
+ if d .authorizer != nil && d . sender != nil {
305
305
storageAccountsClient .Authorizer = d .authorizer
306
- } else {
307
- cloudConfig := cloud.Configuration {
308
- ActiveDirectoryAuthorityHost : environment .ActiveDirectoryEndpoint ,
309
- Services : map [cloud.ServiceName ]cloud.ServiceConfiguration {
310
- cloud .ResourceManager : {
311
- Audience : environment .TokenAudience ,
312
- Endpoint : environment .ResourceManagerEndpoint ,
313
- },
314
- },
315
- }
316
- options := azidentity.ClientSecretCredentialOptions {
317
- ClientOptions : azcore.ClientOptions {
318
- Cloud : cloudConfig ,
319
- },
320
- }
321
- cred , err := azidentity .NewClientSecretCredential (cfg .TenantID , cfg .ClientID , cfg .ClientSecret , & options )
322
- if err != nil {
323
- return storage.AccountsClient {}, err
324
- }
325
- scope := environment .TokenAudience
326
- if ! strings .HasSuffix (scope , "/.default" ) {
327
- scope += "/.default"
328
- }
329
-
330
- storageAccountsClient .Authorizer = azidext .NewTokenCredentialAdapter (cred , []string {scope })
306
+ storageAccountsClient .Sender = d .sender
307
+ return storageAccountsClient , nil
331
308
}
332
309
333
- if d .sender != nil {
334
- storageAccountsClient .Sender = d .sender
310
+ cloudConfig := cloud.Configuration {
311
+ ActiveDirectoryAuthorityHost : environment .ActiveDirectoryEndpoint ,
312
+ Services : map [cloud.ServiceName ]cloud.ServiceConfiguration {
313
+ cloud .ResourceManager : {
314
+ Audience : environment .TokenAudience ,
315
+ Endpoint : environment .ResourceManagerEndpoint ,
316
+ },
317
+ },
318
+ }
319
+ options := azidentity.ClientSecretCredentialOptions {
320
+ ClientOptions : azcore.ClientOptions {
321
+ Cloud : cloudConfig ,
322
+ },
335
323
}
324
+ cred , err := azidentity .NewClientSecretCredential (cfg .TenantID , cfg .ClientID , cfg .ClientSecret , & options )
325
+ if err != nil {
326
+ return storage.AccountsClient {}, err
327
+ }
328
+ scope := environment .TokenAudience
329
+ if ! strings .HasSuffix (scope , "/.default" ) {
330
+ scope += "/.default"
331
+ }
332
+
333
+ storageAccountsClient .Authorizer = azidext .NewTokenCredentialAdapter (cred , []string {scope })
336
334
337
335
return storageAccountsClient , nil
338
336
}
0 commit comments