Prometheus: (Chore) Switch to sdk httpclient from infra httpclient (#76955)

This commit is contained in:
Kyle Brandt
2023-10-23 10:40:43 -04:00
committed by GitHub
parent 9dc6cac1f2
commit 1b420585f9
5 changed files with 53 additions and 52 deletions
+9 -10
View File
@@ -11,9 +11,6 @@ import (
"testing"
"time"
"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/data"
apiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
p "github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
@@ -22,8 +19,10 @@ import (
"github.com/grafana/kindsys"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana/pkg/infra/httpclient"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb/prometheus/client"
@@ -430,8 +429,8 @@ type testContext struct {
func setup() (*testContext, error) {
tracer := tracing.InitializeTracerForTest()
httpProvider := &fakeHttpClientProvider{
opts: sdkhttpclient.Options{
Timeouts: &sdkhttpclient.DefaultTimeoutOptions,
opts: httpclient.Options{
Timeouts: &httpclient.DefaultTimeoutOptions,
},
res: &http.Response{
StatusCode: 200,
@@ -473,14 +472,14 @@ func (f *fakeFeatureToggles) IsEnabled(feature string) bool {
type fakeHttpClientProvider struct {
httpclient.Provider
opts sdkhttpclient.Options
opts httpclient.Options
req *http.Request
res *http.Response
}
func (p *fakeHttpClientProvider) New(opts ...sdkhttpclient.Options) (*http.Client, error) {
func (p *fakeHttpClientProvider) New(opts ...httpclient.Options) (*http.Client, error) {
p.opts = opts[0]
c, err := sdkhttpclient.New(opts[0])
c, err := httpclient.New(opts[0])
if err != nil {
return nil, err
}
@@ -488,7 +487,7 @@ func (p *fakeHttpClientProvider) New(opts ...sdkhttpclient.Options) (*http.Clien
return c, 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 http.DefaultTransport, nil
}