AzureMonitor: Remove infra client (#74113)

remove infra client from azure monitor
This commit is contained in:
Andrew Hackmann 2023-09-05 09:00:21 -05:00 committed by GitHub
parent 27ed2a0f7e
commit 41ca13418b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -1,19 +1,26 @@
package azuremonitor
import (
"crypto/tls"
"fmt"
"net/http"
"github.com/grafana/grafana-azure-sdk-go/azcredentials"
"github.com/grafana/grafana-azure-sdk-go/azhttpclient"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana/pkg/infra/httpclient"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
)
func newHTTPClient(route types.AzRoute, model types.DatasourceInfo, settings *backend.DataSourceInstanceSettings, cfg *setting.Cfg, clientProvider httpclient.Provider) (*http.Client, error) {
type Provider interface {
New(...httpclient.Options) (*http.Client, error)
GetTransport(...httpclient.Options) (http.RoundTripper, error)
GetTLSConfig(...httpclient.Options) (*tls.Config, error)
}
func newHTTPClient(route types.AzRoute, model types.DatasourceInfo, settings *backend.DataSourceInstanceSettings, cfg *setting.Cfg, clientProvider Provider) (*http.Client, error) {
clientOpts, err := settings.HTTPClientOptions()
if err != nil {
return nil, fmt.Errorf("error getting HTTP options: %w", err)

View File

@ -8,9 +8,8 @@ import (
"github.com/grafana/grafana-azure-sdk-go/azcredentials"
"github.com/grafana/grafana-plugin-sdk-go/backend"
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana/pkg/infra/httpclient"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
"github.com/stretchr/testify/assert"
@ -89,20 +88,20 @@ func TestHttpClient_AzureCredentials(t *testing.T) {
type fakeHttpClientProvider struct {
httpclient.Provider
opts sdkhttpclient.Options
opts httpclient.Options
}
func (p *fakeHttpClientProvider) New(opts ...sdkhttpclient.Options) (*http.Client, error) {
func (p *fakeHttpClientProvider) New(opts ...httpclient.Options) (*http.Client, error) {
p.opts = opts[0]
return nil, nil
}
func (p *fakeHttpClientProvider) GetTransport(opts ...sdkhttpclient.Options) (http.RoundTripper, error) {
func (p *fakeHttpClientProvider) GetTransport(opts ...httpclient.Options) (http.RoundTripper, error) {
p.opts = opts[0]
return nil, nil
}
func (p *fakeHttpClientProvider) GetTLSConfig(opts ...sdkhttpclient.Options) (*tls.Config, error) {
func (p *fakeHttpClientProvider) GetTLSConfig(opts ...httpclient.Options) (*tls.Config, error) {
p.opts = opts[0]
return nil, nil
}