Skip to content

Commit

Permalink
remove dependency to github.com/prometheus/client_golang in sigv4
Browse files Browse the repository at this point in the history
Replace promhttp.RoundTripperFunc with local version.

Signed-off-by: Saeed Rasooli <saeed.gnu@gmail.com>
  • Loading branch information
ilius authored Jul 14, 2024
1 parent 8742f09 commit 3e6afe2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sigv4/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ replace github.com/prometheus/common => ../

require (
github.com/aws/aws-sdk-go v1.54.7
github.com/prometheus/client_golang v1.19.1
github.com/prometheus/common v0.53.0
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -22,6 +21,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
golang.org/x/net v0.26.0 // indirect
Expand Down
10 changes: 8 additions & 2 deletions sigv4/sigv4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
signer "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stretchr/testify/require"
)

type RoundTripperFunc func(req *http.Request) (*http.Response, error)

// RoundTrip implements the RoundTripper interface.
func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {
return rt(r)
}

func TestSigV4_Inferred_Region(t *testing.T) {
os.Setenv("AWS_ACCESS_KEY_ID", "secret")
os.Setenv("AWS_SECRET_ACCESS_KEY", "token")
Expand All @@ -50,7 +56,7 @@ func TestSigV4RoundTripper(t *testing.T) {

rt := &sigV4RoundTripper{
region: "us-east-2",
next: promhttp.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
next: RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
gotReq = req
return &http.Response{StatusCode: http.StatusOK}, nil
}),
Expand Down

0 comments on commit 3e6afe2

Please sign in to comment.