forked from TrueCloudLab/restic
azure: deduplicate cli and default credentials case
This commit is contained in:
parent
355f520936
commit
c56ecec9aa
1 changed files with 14 additions and 16 deletions
|
@ -101,24 +101,22 @@ 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")
|
||||
} else {
|
||||
var cred azcore.TokenCredential
|
||||
|
||||
cred, err := azidentity.NewAzureCLICredential(nil)
|
||||
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)
|
||||
cred, err = azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "NewDefaultAzureCredential")
|
||||
}
|
||||
}
|
||||
|
||||
client, err = azContainer.NewClient(url, cred, opts)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue