From 287db1f21fb793520ec33555aad1217026c18739 Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Thu, 24 Oct 2024 14:42:52 +0000 Subject: [PATCH] remove the prefix from version tag --- auth/auth.go | 3 ++- auth/auth_test.go | 3 ++- auth/user_mgt_test.go | 2 +- messaging/messaging.go | 3 ++- messaging/messaging_test.go | 4 +++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 8884bf68..0bda04a0 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -134,11 +134,12 @@ func NewClient(ctx context.Context, conf *internal.AuthConfig) (*Client, error) return nil, err } + goVersion := strings.TrimPrefix(runtime.Version(), "go") hc := internal.WithDefaultRetryConfig(transport) hc.CreateErrFn = handleHTTPError hc.Opts = []internal.HTTPOption{ internal.WithHeader("X-Client-Version", fmt.Sprintf("Go/Admin/%s", conf.Version)), - internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", runtime.Version(), conf.Version)), + internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)), } baseURL := defaultAuthURL diff --git a/auth/auth_test.go b/auth/auth_test.go index 0223f8b2..2a00220b 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -1452,8 +1452,9 @@ func checkBaseClient(client *Client, wantProjectID string) error { return fmt.Errorf("version = %q; want = %q", version, wantVersion) } + goVersion := strings.TrimPrefix(runtime.Version(), "go") xGoogAPIClientHeader := req.Header.Get("x-goog-api-client") - wantXGoogAPIClientHeader := fmt.Sprintf("gl-go/%s fire-admin/%s", runtime.Version(), testVersion) + wantXGoogAPIClientHeader := fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, testVersion) if xGoogAPIClientHeader != wantXGoogAPIClientHeader { return fmt.Errorf("x-goog-api-client header = %q; want = %q", xGoogAPIClientHeader, wantXGoogAPIClientHeader) } diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index 55cfd3a4..902ed280 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -2317,7 +2317,7 @@ func echoServer(resp interface{}, t *testing.T) *mockAuthServer { } gh = r.Header.Get("x-goog-api-client") - wh = fmt.Sprintf("gl-go/%s fire-admin/%s", runtime.Version(), testVersion) + wh = fmt.Sprintf("gl-go/%s fire-admin/%s", strings.TrimPrefix(runtime.Version(), "go"), testVersion) if gh != wh { t.Errorf("x-goog-api-client header = %q; want: %q", gh, wh) } diff --git a/messaging/messaging.go b/messaging/messaging.go index 12271a9a..525cccb6 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -894,11 +894,12 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, messagingEndp client := internal.WithDefaultRetryConfig(hc) client.CreateErrFn = handleFCMError + goVersion := strings.TrimPrefix(runtime.Version(), "go") version := fmt.Sprintf("fire-admin-go/%s", conf.Version) client.Opts = []internal.HTTPOption{ internal.WithHeader(apiFormatVersionHeader, apiFormatVersion), internal.WithHeader(firebaseClientHeader, version), - internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", runtime.Version(), conf.Version)), + internal.WithHeader("x-goog-api-client", fmt.Sprintf("gl-go/%s fire-admin/%s", goVersion, conf.Version)), } return &fcmClient{ diff --git a/messaging/messaging_test.go b/messaging/messaging_test.go index a57e5c7e..8b31fc46 100644 --- a/messaging/messaging_test.go +++ b/messaging/messaging_test.go @@ -22,6 +22,7 @@ import ( "net/http/httptest" "reflect" "runtime" + "strings" "testing" "time" @@ -1395,7 +1396,8 @@ func checkFCMRequest(t *testing.T, b []byte, tr *http.Request, want map[string]i if h := tr.Header.Get("X-FIREBASE-CLIENT"); h != clientVersion { t.Errorf("X-FIREBASE-CLIENT = %q; want = %q", h, clientVersion) } - xGoogAPIClientHeader := "gl-go/" + runtime.Version() + " fire-admin/" + testMessagingConfig.Version + goVersion := strings.TrimPrefix(runtime.Version(), "go") + xGoogAPIClientHeader := "gl-go/" + goVersion + " fire-admin/" + testMessagingConfig.Version if h := tr.Header.Get("x-goog-api-client"); h != xGoogAPIClientHeader { t.Errorf("x-goog-api-client header = %q; want = %q", h, xGoogAPIClientHeader) }