From c04763b4559d080430a5b1dbb8db745a88fc6655 Mon Sep 17 00:00:00 2001 From: Jonathan Edey Date: Tue, 19 Nov 2024 13:01:03 -0500 Subject: [PATCH] Fix lint and test --- auth/token_generator.go | 6 +++--- iid/iid.go | 6 +++--- internal/http_client.go | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/auth/token_generator.go b/auth/token_generator.go index ddf777be..7aa2d564 100644 --- a/auth/token_generator.go +++ b/auth/token_generator.go @@ -172,12 +172,12 @@ type iamSigner struct { func newIAMSigner(ctx context.Context, config *internal.AuthConfig) (*iamSigner, error) { hc, _, err := internal.NewHTTPClient(ctx, config.Opts...) - hc.Opts = []internal.HTTPOption{ - internal.WithHeader("x-goog-api-client", internal.GetMetricsHeader(config.Version)), - } if err != nil { return nil, err } + hc.Opts = []internal.HTTPOption{ + internal.WithHeader("x-goog-api-client", internal.GetMetricsHeader(config.Version)), + } return &iamSigner{ mutex: &sync.Mutex{}, diff --git a/iid/iid.go b/iid/iid.go index 259f3c36..7a3e9b55 100644 --- a/iid/iid.go +++ b/iid/iid.go @@ -116,12 +116,12 @@ func NewClient(ctx context.Context, c *internal.InstanceIDConfig) (*Client, erro } hc, _, err := internal.NewHTTPClient(ctx, c.Opts...) - hc.Opts = []internal.HTTPOption{ - internal.WithHeader("x-goog-api-client", internal.GetMetricsHeader(c.Version)), - } if err != nil { return nil, err } + hc.Opts = []internal.HTTPOption{ + internal.WithHeader("x-goog-api-client", internal.GetMetricsHeader(c.Version)), + } hc.CreateErrFn = createError return &Client{ diff --git a/internal/http_client.go b/internal/http_client.go index 9adffefd..9463f98e 100644 --- a/internal/http_client.go +++ b/internal/http_client.go @@ -444,6 +444,7 @@ func retryNetworkAndHTTPErrors(statusCodes ...int) RetryCondition { } } +// GetMetricsHeader constructs header value for metrics attribution func GetMetricsHeader(sdkVersion string) string { goVersion := strings.TrimPrefix(runtime.Version(), "go") return fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, sdkVersion)