mirror of
https://github.com/octoleo/restic.git
synced 2024-12-24 03:45:27 +00:00
azure: deduplicate cli and default credentials case
This commit is contained in:
parent
834f08fe2d
commit
12e858b7af
@ -101,23 +101,21 @@ func open(cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewAccountSASClientFromEndpointToken")
|
||||
}
|
||||
} else if cfg.ForceCliCredential {
|
||||
debug.Log(" - using AzureCLICredential")
|
||||
|
||||
cred, err := azidentity.NewAzureCLICredential(nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewAzureCLICredential")
|
||||
}
|
||||
|
||||
client, err = azContainer.NewClient(url, cred, opts)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewClient")
|
||||
}
|
||||
} else {
|
||||
debug.Log(" - using DefaultAzureCredential")
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewDefaultAzureCredential")
|
||||
var cred azcore.TokenCredential
|
||||
|
||||
if cfg.ForceCliCredential {
|
||||
debug.Log(" - using AzureCLICredential")
|
||||
cred, err = azidentity.NewAzureCLICredential(nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewAzureCLICredential")
|
||||
}
|
||||
} else {
|
||||
debug.Log(" - using DefaultAzureCredential")
|
||||
cred, err = azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewDefaultAzureCredential")
|
||||
}
|
||||
}
|
||||
|
||||
client, err = azContainer.NewClient(url, cred, opts)
|
||||
|
Loading…
Reference in New Issue
Block a user