From 13fe0bc0d8acbffd46b59ab69b25449f1cbd6a88 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Thu, 10 Feb 2022 14:48:19 -0700 Subject: [PATCH] feat(storage): add better version metadata to calls (#5507) Adding a new file that should be maintained auotmatically by release-please. Updates: #2749 --- storage/internal/version.go | 18 ++++++++++++++++++ storage/storage.go | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 storage/internal/version.go diff --git a/storage/internal/version.go b/storage/internal/version.go new file mode 100644 index 000000000000..0b0f0e914120 --- /dev/null +++ b/storage/internal/version.go @@ -0,0 +1,18 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +// Version is the current tagged release of the library. +const Version = "1.20.0" diff --git a/storage/storage.go b/storage/storage.go index 07a5ee077c33..457d77c8dbc9 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -40,6 +40,7 @@ import ( "cloud.google.com/go/internal/optional" "cloud.google.com/go/internal/trace" "cloud.google.com/go/internal/version" + "cloud.google.com/go/storage/internal" gapic "cloud.google.com/go/storage/internal/apiv2" "github.com/googleapis/gax-go/v2" "golang.org/x/oauth2/google" @@ -69,7 +70,7 @@ var ( errMethodNotValid = fmt.Errorf("storage: HTTP method should be one of %v", reflect.ValueOf(signedURLMethods).MapKeys()) ) -var userAgent = fmt.Sprintf("gcloud-golang-storage/%s", version.Repo) +var userAgent = fmt.Sprintf("gcloud-golang-storage/%s", internal.Version) const ( // ScopeFullControl grants permissions to manage your @@ -91,7 +92,7 @@ const ( defaultConnPoolSize = 4 ) -var xGoogHeader = fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), version.Repo) +var xGoogHeader = fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), internal.Version) func setClientHeader(headers http.Header) { headers.Set("x-goog-api-client", xGoogHeader)