Fix error source for clientSecret not found error (#96771)

* Fix error source for clientSecret not found errir

* Use errors.New as we are not formatting the error
This commit is contained in:
Ivana Huckova 2024-11-20 17:16:02 +01:00 committed by GitHub
parent 1f37311de4
commit 6b5a05486b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package azuremonitor
import (
"context"
"crypto/tls"
"errors"
"fmt"
"net/http"
@ -34,7 +35,7 @@ func newHTTPClient(ctx context.Context, route types.AzRoute, model types.Datasou
// Use Azure credentials if the route has OAuth scopes configured
if len(route.Scopes) > 0 {
if cred, ok := model.Credentials.(*azcredentials.AzureClientSecretCredentials); ok && cred.ClientSecret == "" {
return nil, fmt.Errorf("unable to initialize HTTP Client: clientSecret not found")
return nil, backend.DownstreamError(errors.New("unable to initialize HTTP Client: clientSecret not found"))
}
authOpts := azhttpclient.NewAuthOptions(azureSettings)