From d1ad921d0322e7ce728ca9d255a3cf0437d26add Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Fri, 11 Feb 2022 15:36:16 -0700 Subject: [PATCH] chore: bulk update version for manual (#5516) This changes bulk updates all manuals that has reference to the old version.Repo that has been a long incorrect value. This new version files will be maintained by release please. Updates: #2749 feat(bigquery): add better version metadata to calls feat(datastore): add better version metadata to calls feat(errorreporting): add better version metadata to calls feat(firestore): add better version metadata to calls feat(logging): add better version metadata to calls feat(profiler): add better version metadata to calls feat(pubsub): add better version metadata to calls feat(translate): add better version metadata to calls --- bigquery/bigquery.go | 9 +- bigquery/internal/version.go | 18 ++++ datastore/client.go | 7 +- datastore/internal/version.go | 18 ++++ errorreporting/errors.go | 4 +- errorreporting/internal/version.go | 18 ++++ firestore/client.go | 4 +- firestore/internal/Makefile | 16 --- firestore/internal/doc-snippets.go | 162 ----------------------------- firestore/internal/doc.template | 145 -------------------------- firestore/internal/snipdoc.awk | 116 --------------------- firestore/internal/version.go | 18 ++++ logging/internal/version.go | 18 ++++ logging/logadmin/logadmin.go | 7 +- logging/logging.go | 3 +- profiler/internal/version.go | 18 ++++ profiler/profiler.go | 7 +- pubsub/internal/version.go | 18 ++++ pubsub/pubsub.go | 4 +- translate/internal/version.go | 18 ++++ translate/translate.go | 3 +- 21 files changed, 169 insertions(+), 462 deletions(-) create mode 100644 bigquery/internal/version.go create mode 100644 datastore/internal/version.go create mode 100644 errorreporting/internal/version.go delete mode 100644 firestore/internal/Makefile delete mode 100644 firestore/internal/doc-snippets.go delete mode 100644 firestore/internal/doc.template delete mode 100644 firestore/internal/snipdoc.awk create mode 100644 firestore/internal/version.go create mode 100644 logging/internal/version.go create mode 100644 profiler/internal/version.go create mode 100644 pubsub/internal/version.go create mode 100644 translate/internal/version.go diff --git a/bigquery/bigquery.go b/bigquery/bigquery.go index 54800f8417b9..7647a9c8b2bb 100644 --- a/bigquery/bigquery.go +++ b/bigquery/bigquery.go @@ -23,7 +23,8 @@ import ( "strings" "time" - "cloud.google.com/go/internal" + "cloud.google.com/go/bigquery/internal" + cloudinternal "cloud.google.com/go/internal" "cloud.google.com/go/internal/detect" "cloud.google.com/go/internal/version" gax "github.com/googleapis/gax-go/v2" @@ -40,7 +41,7 @@ const ( userAgentPrefix = "gcloud-golang-bigquery" ) -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) @@ -74,7 +75,7 @@ const DetectProjectID = "*detect-project-id*" func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (*Client, error) { o := []option.ClientOption{ option.WithScopes(Scope), - option.WithUserAgent(fmt.Sprintf("%s/%s", userAgentPrefix, version.Repo)), + option.WithUserAgent(fmt.Sprintf("%s/%s", userAgentPrefix, internal.Version)), } o = append(o, opts...) bqs, err := bq.NewService(ctx, o...) @@ -185,7 +186,7 @@ func runWithRetryExplicit(ctx context.Context, call func() error, allowedReasons Max: 32 * time.Second, Multiplier: 2, } - return internal.Retry(ctx, backoff, func() (stop bool, err error) { + return cloudinternal.Retry(ctx, backoff, func() (stop bool, err error) { err = call() if err == nil { return true, nil diff --git a/bigquery/internal/version.go b/bigquery/internal/version.go new file mode 100644 index 000000000000..dc1cb9f6009b --- /dev/null +++ b/bigquery/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.27.0" diff --git a/datastore/client.go b/datastore/client.go index 2792fb5209e6..6cc6b4935354 100644 --- a/datastore/client.go +++ b/datastore/client.go @@ -19,7 +19,8 @@ import ( "fmt" "time" - "cloud.google.com/go/internal" + "cloud.google.com/go/datastore/internal" + cloudinternal "cloud.google.com/go/internal" "cloud.google.com/go/internal/trace" "cloud.google.com/go/internal/version" gax "github.com/googleapis/gax-go/v2" @@ -46,7 +47,7 @@ func newDatastoreClient(conn grpc.ClientConnInterface, projectID string) pb.Data c: pb.NewDatastoreClient(conn), md: metadata.Pairs( resourcePrefixHeader, "projects/"+projectID, - "x-goog-api-client", fmt.Sprintf("gl-go/%s gccl/%s grpc/", version.Go(), version.Repo)), + "x-goog-api-client", fmt.Sprintf("gl-go/%s gccl/%s grpc/", version.Go(), internal.Version)), } } @@ -118,7 +119,7 @@ func (dc *datastoreClient) AllocateIds(ctx context.Context, in *pb.AllocateIdsRe func (dc *datastoreClient) invoke(ctx context.Context, f func(ctx context.Context) error) error { ctx = metadata.NewOutgoingContext(ctx, dc.md) - return internal.Retry(ctx, gax.Backoff{Initial: 100 * time.Millisecond}, func() (stop bool, err error) { + return cloudinternal.Retry(ctx, gax.Backoff{Initial: 100 * time.Millisecond}, func() (stop bool, err error) { err = f(ctx) return !shouldRetry(err), err }) diff --git a/datastore/internal/version.go b/datastore/internal/version.go new file mode 100644 index 000000000000..05d3396f1001 --- /dev/null +++ b/datastore/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.6.0" diff --git a/errorreporting/errors.go b/errorreporting/errors.go index 25683e7c0d87..e83c189b0ff9 100644 --- a/errorreporting/errors.go +++ b/errorreporting/errors.go @@ -33,7 +33,7 @@ import ( "time" vkit "cloud.google.com/go/errorreporting/apiv1beta1" - "cloud.google.com/go/internal/version" + "cloud.google.com/go/errorreporting/internal" "github.com/golang/protobuf/ptypes" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/option" @@ -88,7 +88,7 @@ var newClient = func(ctx context.Context, opts ...option.ClientOption) (client, if err != nil { return nil, err } - client.SetGoogleClientInfo("gccl", version.Repo) + client.SetGoogleClientInfo("gccl", internal.Version) return client, nil } diff --git a/errorreporting/internal/version.go b/errorreporting/internal/version.go new file mode 100644 index 000000000000..b74ae121b41e --- /dev/null +++ b/errorreporting/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 = "0.1.0" diff --git a/firestore/client.go b/firestore/client.go index 1b4c4618672a..35d695a3e749 100644 --- a/firestore/client.go +++ b/firestore/client.go @@ -24,8 +24,8 @@ import ( "time" vkit "cloud.google.com/go/firestore/apiv1" + "cloud.google.com/go/firestore/internal" "cloud.google.com/go/internal/trace" - "cloud.google.com/go/internal/version" "github.com/golang/protobuf/ptypes" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/iterator" @@ -92,7 +92,7 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio if err != nil { return nil, err } - vc.SetGoogleClientInfo("gccl", version.Repo) + vc.SetGoogleClientInfo("gccl", internal.Version) c := &Client{ c: vc, projectID: projectID, diff --git a/firestore/internal/Makefile b/firestore/internal/Makefile deleted file mode 100644 index 6769cb36eab3..000000000000 --- a/firestore/internal/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Build doc.go from template and snippets. - -SHELL=/bin/bash - -../doc.go: build doc-snippets.go doc.template snipdoc.awk - @tmp=$$(mktemp) && \ - awk -f snipdoc.awk doc-snippets.go doc.template > $$tmp && \ - chmod +w $@ && \ - mv $$tmp $@ && \ - chmod -w $@ - @echo "wrote $@" - -.PHONY: build - -build: - go build doc-snippets.go diff --git a/firestore/internal/doc-snippets.go b/firestore/internal/doc-snippets.go deleted file mode 100644 index 9089bf6324bf..000000000000 --- a/firestore/internal/doc-snippets.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2017 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 - -// TODO(deklerk): can this file and directory be deleted, or is it being used for documentation somewhere? - -import ( - "context" - "fmt" - - firestore "cloud.google.com/go/firestore" - "google.golang.org/api/iterator" -) - -// State represents a state. -//[ structDef -type State struct { - Capital string `firestore:"capital"` - Population float64 `firestore:"pop"` // in millions -} - -//] - -func f1() { - //[ NewClient - ctx := context.Background() - client, err := firestore.NewClient(ctx, "projectID") - if err != nil { - // TODO: Handle error. - } - //] - //[ refs - states := client.Collection("States") - ny := states.Doc("NewYork") - // Or, in a single call: - ny = client.Doc("States/NewYork") - //] - //[ docref.Get - docsnap, err := ny.Get(ctx) - if err != nil { - // TODO: Handle error. - } - dataMap := docsnap.Data() - fmt.Println(dataMap) - //] - //[ DataTo - var nyData State - if err := docsnap.DataTo(&nyData); err != nil { - // TODO: Handle error. - } - //] - //[ GetAll - docsnaps, err := client.GetAll(ctx, []*firestore.DocumentRef{ - states.Doc("Wisconsin"), states.Doc("Ohio"), - }) - if err != nil { - // TODO: Handle error. - } - for _, ds := range docsnaps { - _ = ds // TODO: Use ds. - } - //[ docref.Create - wr, err := ny.Create(ctx, State{ - Capital: "Albany", - Population: 19.8, - }) - if err != nil { - // TODO: Handle error. - } - fmt.Println(wr) - //] - //[ docref.Set - ca := states.Doc("California") - _, err = ca.Set(ctx, State{ - Capital: "Sacramento", - Population: 39.14, - }) - //] - - //[ docref.Update - _, err = ca.Update(ctx, []firestore.Update{{Path: "capital", Value: "Sacramento"}}) - //] - - //[ docref.Delete - _, err = ny.Delete(ctx) - //] - - //[ LUT-precond - docsnap, err = ca.Get(ctx) - if err != nil { - // TODO: Handle error. - } - _, err = ca.Update(ctx, - []firestore.Update{{Path: "capital", Value: "Sacramento"}}, - firestore.LastUpdateTime(docsnap.UpdateTime)) - //] - - //[ WriteBatch - writeResults, err := client.Batch(). - Create(ny, State{Capital: "Albany"}). - Update(ca, []firestore.Update{{Path: "capital", Value: "Sacramento"}}). - Delete(client.Doc("States/WestDakota")). - Commit(ctx) - //] - _ = writeResults - - //[ Query - q := states.Where("pop", ">", 10).OrderBy("pop", firestore.Desc) - //] - //[ Documents - // import "google.golang.org/api/iterator" - iter := q.Documents(ctx) - for { - doc, err := iter.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - fmt.Println(doc.Data()) - } - //] - - //[ CollQuery - iter = client.Collection("States").Documents(ctx) - //] -} - -func txn() { - var ctx context.Context - var client *firestore.Client - //[ Transaction - ny := client.Doc("States/NewYork") - err := client.RunTransaction(ctx, func(ctx context.Context, tx *firestore.Transaction) error { - doc, err := tx.Get(ny) // tx.Get, NOT ny.Get! - if err != nil { - return err - } - pop, err := doc.DataAt("pop") - if err != nil { - return err - } - return tx.Update(ny, []firestore.Update{{Path: "pop", Value: pop.(float64) + 0.2}}) - }) - if err != nil { - // TODO: Handle error. - } - //] -} diff --git a/firestore/internal/doc.template b/firestore/internal/doc.template deleted file mode 100644 index 6d428235a810..000000000000 --- a/firestore/internal/doc.template +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2017 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. - -// DO NOT EDIT doc.go. Modify internal/doc.template, then run make -C internal. - -/* -Package firestore provides a client for reading and writing to a Cloud Firestore -database. - -See https://cloud.google.com/firestore/docs for an introduction -to Cloud Firestore and additional help on using the Firestore API. - -Note: you can't use both Cloud Firestore and Cloud Datastore in the same -project. - -Creating a Client - -To start working with this package, create a client with a project ID: - -[NewClient] - -CollectionRefs and DocumentRefs - -In Firestore, documents are sets of key-value pairs, and collections are groups of -documents. A Firestore database consists of a hierarchy of alternating collections -and documents, referred to by slash-separated paths like -"States/California/Cities/SanFrancisco". - -This client is built around references to collections and documents. CollectionRefs -and DocumentRefs are lightweight values that refer to the corresponding database -entities. Creating a ref does not involve any network traffic. - -[refs] - -Reading - -Use DocumentRef.Get to read a document. The result is a DocumentSnapshot. -Call its Data method to obtain the entire document contents as a map. - -[docref.Get] - -You can also obtain a single field with DataAt, or extract the data into a struct -with DataTo. With the type definition - -[structDef] - -we can extract the document's data into a value of type State: - -[DataTo] - -Note that this client supports struct tags beginning with "firestore:" that work like -the tags of the encoding/json package, letting you rename fields, ignore them, or -omit their values when empty. - -To retrieve multiple documents from their references in a single call, use -Client.GetAll. - -[GetAll] - -Writing - -For writing individual documents, use the methods on DocumentReference. -Create creates a new document. - -[docref.Create] - -The first return value is a WriteResult, which contains the time -at which the document was updated. - -Create fails if the document exists. Another method, Set, either replaces an existing -document or creates a new one. - -[docref.Set] - -To update some fields of an existing document, use Update. It takes a list of -paths to update and their corresponding values. - -[docref.Update] - -Use DocumentRef.Delete to delete a document. - -[docref.Delete] - -Preconditions - -You can condition Deletes or Updates on when a document was last changed. Specify -these preconditions as an option to a Delete or Update method. The check and the -write happen atomically with a single RPC. - -[LUT-precond] - -Here we update a doc only if it hasn't changed since we read it. -You could also do this with a transaction. - -To perform multiple writes at once, use a WriteBatch. Its methods chain -for convenience. - -WriteBatch.Commit sends the collected writes to the server, where they happen -atomically. - -[WriteBatch] - -Queries - -You can use SQL to select documents from a collection. Begin with the collection, and -build up a query using Select, Where and other methods of Query. - -[Query] - -Call the Query's Documents method to get an iterator, and use it like -the other Google Cloud Client iterators. - -[Documents] - -To get all the documents in a collection, you can use the collection itself -as a query. - -[CollQuery] - -Transactions - -Use a transaction to execute reads and writes atomically. All reads must happen -before any writes. Transaction creation, commit, rollback and retry are handled for -you by the Client.RunTransaction method; just provide a function and use the -read and write methods of the Transaction passed to it. - -[Transaction] - -Authentication - -See examples of authorization and authentication at -https://godoc.org/cloud.google.com/go#pkg-examples. -*/ -package firestore diff --git a/firestore/internal/snipdoc.awk b/firestore/internal/snipdoc.awk deleted file mode 100644 index 98e788ebdf73..000000000000 --- a/firestore/internal/snipdoc.awk +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright 2017 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. - -# snipdoc merges code snippets from Go source files into a template to -# produce another go file (typically doc.go). -# -# Call with one or more .go files and a template file. -# -# awk -f snipmd.awk foo.go bar.go doc.template -# -# In the Go files, start a snippet with -# //[ NAME -# and end it with -# //] -# -# In the template, write -# [NAME] -# on a line by itself to insert the snippet NAME on that line. -# -# The following transformations are made to the Go code: -# - Trailing blank lines are removed. -# - `ELLIPSIS` and `_ = ELLIPSIS` are replaced by `...` - - -/^[ \t]*\/\/\[/ { # start snippet in Go file - if (inGo()) { - if ($2 == "") { - die("missing snippet name") - } - curSnip = $2 - next - } -} - -/^[ \t]*\/\/]/ { # end snippet in Go file - if (inGo()) { - if (curSnip != "") { - # Remove all trailing newlines. - gsub(/[\t\n]+$/, "", snips[curSnip]) - curSnip = "" - next - } else { - die("//] without corresponding //[") - } - } -} - -ENDFILE { - if (curSnip != "") { - die("unclosed snippet: " curSnip) - } -} - -/^\[.*\]$/ { # Snippet marker in template file. - if (inTemplate()) { - name = substr($1, 2, length($1)-2) - if (snips[name] == "") { - die("no snippet named " name) - } - printf("%s\n", snips[name]) - afterSnip = 1 - next - } -} - -# Matches every line. -{ - if (curSnip != "") { - # If the first line in the snip has no indent, add the indent. - if (snips[curSnip] == "") { - if (index($0, "\t") == 1) { - extraIndent = "" - } else { - extraIndent = "\t" - } - } - - line = $0 - # Replace ELLIPSIS. - gsub(/_ = ELLIPSIS/, "...", line) - gsub(/ELLIPSIS/, "...", line) - - snips[curSnip] = snips[curSnip] extraIndent line "\n" - } else if (inTemplate()) { - afterSnip = 0 - # Copy to output. - print - } -} - - - -function inTemplate() { - return match(FILENAME, /\.template$/) -} - -function inGo() { - return match(FILENAME, /\.go$/) -} - - -function die(msg) { - printf("%s:%d: %s\n", FILENAME, FNR, msg) > "/dev/stderr" - exit 1 -} diff --git a/firestore/internal/version.go b/firestore/internal/version.go new file mode 100644 index 000000000000..b819fa786d1c --- /dev/null +++ b/firestore/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.6.1" diff --git a/logging/internal/version.go b/logging/internal/version.go new file mode 100644 index 000000000000..5a350533db55 --- /dev/null +++ b/logging/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.4.2" diff --git a/logging/logadmin/logadmin.go b/logging/logadmin/logadmin.go index d6ffc31f045c..12329d01c493 100644 --- a/logging/logadmin/logadmin.go +++ b/logging/logadmin/logadmin.go @@ -33,7 +33,6 @@ import ( "strings" "time" - "cloud.google.com/go/internal/version" "cloud.google.com/go/logging" vkit "cloud.google.com/go/logging/apiv2" "cloud.google.com/go/logging/internal" @@ -95,9 +94,9 @@ func NewClient(ctx context.Context, parent string, opts ...option.ClientOption) mc.CallOptions.CreateLogMetric = []gax.CallOption{gax.WithRetry(retryerOnInternal)} mc.CallOptions.UpdateLogMetric = []gax.CallOption{gax.WithRetry(retryerOnInternal)} - lc.SetGoogleClientInfo("gccl", version.Repo) - sc.SetGoogleClientInfo("gccl", version.Repo) - mc.SetGoogleClientInfo("gccl", version.Repo) + lc.SetGoogleClientInfo("gccl", internal.Version) + sc.SetGoogleClientInfo("gccl", internal.Version) + mc.SetGoogleClientInfo("gccl", internal.Version) client := &Client{ lClient: lc, sClient: sc, diff --git a/logging/logging.go b/logging/logging.go index 6f990f26a149..f344cc6880c2 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -39,7 +39,6 @@ import ( "time" "unicode/utf8" - "cloud.google.com/go/internal/version" vkit "cloud.google.com/go/logging/apiv2" "cloud.google.com/go/logging/internal" "github.com/golang/protobuf/proto" @@ -143,7 +142,7 @@ func NewClient(ctx context.Context, parent string, opts ...option.ClientOption) if err != nil { return nil, err } - c.SetGoogleClientInfo("gccl", version.Repo) + c.SetGoogleClientInfo("gccl", internal.Version) client := &Client{ client: c, parent: parent, diff --git a/profiler/internal/version.go b/profiler/internal/version.go new file mode 100644 index 000000000000..a9b0ea53c7b1 --- /dev/null +++ b/profiler/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 = "0.1.2" diff --git a/profiler/profiler.go b/profiler/profiler.go index c6f90e8b1e18..003bcab2650b 100644 --- a/profiler/profiler.go +++ b/profiler/profiler.go @@ -50,6 +50,7 @@ import ( gcemd "cloud.google.com/go/compute/metadata" "cloud.google.com/go/internal/version" + "cloud.google.com/go/profiler/internal" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" "github.com/google/pprof/profile" @@ -240,7 +241,7 @@ func start(cfg Config, options ...option.ClientOption) error { opts := []option.ClientOption{ option.WithEndpoint(config.APIAddr), option.WithScopes(scope), - option.WithUserAgent(fmt.Sprintf("gcloud-go-profiler/%s", version.Repo)), + option.WithUserAgent(fmt.Sprintf("gcloud-go-profiler/%s", internal.Version)), } if !config.EnableOCTelemetry { opts = append(opts, option.WithTelemetryDisabled()) @@ -475,7 +476,7 @@ func mutexProfile() (*profile.Profile, error) { // the `x-goog-api-client` header passed on each request. Intended for // use by Google-written clients. func withXGoogHeader(ctx context.Context, keyval ...string) context.Context { - kv := append([]string{"gl-go", version.Go(), "gccl", version.Repo}, keyval...) + kv := append([]string{"gl-go", version.Go(), "gccl", internal.Version}, keyval...) kv = append(kv, "gax", gax.Version, "grpc", grpc.Version) md, _ := grpcmd.FromOutgoingContext(ctx) @@ -610,7 +611,7 @@ func initializeConfig(cfg Config) error { // server for instructions, and collects and uploads profiles as // requested. func pollProfilerService(ctx context.Context, a *agent) { - debugLog("Cloud Profiler Go Agent version: %s", version.Repo) + debugLog("Cloud Profiler Go Agent version: %s", internal.Version) debugLog("profiler has started") for i := 0; config.numProfiles == 0 || i < config.numProfiles; i++ { p := a.createProfile(ctx) diff --git a/pubsub/internal/version.go b/pubsub/internal/version.go new file mode 100644 index 000000000000..ddddbd21f21f --- /dev/null +++ b/pubsub/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.18.0" diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index ec9ac4a55ba8..7ea72ae816c1 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -23,8 +23,8 @@ import ( "strings" "time" - "cloud.google.com/go/internal/version" vkit "cloud.google.com/go/pubsub/apiv1" + "cloud.google.com/go/pubsub/internal" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/option" "google.golang.org/grpc" @@ -158,7 +158,7 @@ func NewClientWithConfig(ctx context.Context, projectID string, config *ClientCo pubc.CallOptions = mergePublisherCallOptions(pubc.CallOptions, config.PublisherCallOptions) subc.CallOptions = mergeSubscriberCallOptions(subc.CallOptions, config.SubscriberCallOptions) } - pubc.SetGoogleClientInfo("gccl", version.Repo) + pubc.SetGoogleClientInfo("gccl", internal.Version) return &Client{ projectID: projectID, pubc: pubc, diff --git a/translate/internal/version.go b/translate/internal/version.go new file mode 100644 index 000000000000..db6d2e3e99d1 --- /dev/null +++ b/translate/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.0.0" diff --git a/translate/translate.go b/translate/translate.go index f389cf7a3f66..95898a1b5464 100644 --- a/translate/translate.go +++ b/translate/translate.go @@ -26,6 +26,7 @@ import ( "net/http" "cloud.google.com/go/internal/version" + "cloud.google.com/go/translate/internal" "golang.org/x/text/language" "google.golang.org/api/option" raw "google.golang.org/api/translate/v2" @@ -236,5 +237,5 @@ type Language struct { } func setClientHeader(headers http.Header) { - headers.Set("x-goog-api-client", fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), version.Repo)) + headers.Set("x-goog-api-client", fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), internal.Version)) }