From e0905d89f89c375cde4ba3bc96d22071f2918283 Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Wed, 15 Apr 2015 18:17:21 -0400 Subject: [PATCH] Add a UserAgent with version temporarily set to 0.0.0 --- builtin/providers/google/config.go | 14 ++++++++++++++ builtin/providers/google/service_scope.go | 1 + 2 files changed, 15 insertions(+) diff --git a/builtin/providers/google/config.go b/builtin/providers/google/config.go index 254cb3ebf..f9a58485f 100644 --- a/builtin/providers/google/config.go +++ b/builtin/providers/google/config.go @@ -6,7 +6,10 @@ import ( "log" "net/http" "os" + "runtime" + // TODO(dcunnin): Use version code from version.go + // "github.com/hashicorp/terraform" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" @@ -83,6 +86,17 @@ func (c *Config) loadAndValidate() error { log.Printf("[INFO] Instantiating GCE client...") var err error c.clientCompute, err = compute.New(client) + + // Set UserAgent + versionString := "0.0.0" + // TODO(dcunnin): Use Terraform's version code from version.go + // versionString := main.Version + // if main.VersionPrerelease != "" { + // versionString = fmt.Sprintf("%s-%s", versionString, main.VersionPrerelease) + // } + c.clientCompute.UserAgent = fmt.Sprintf( + "(%s %s) Terraform/%s", runtime.GOOS, runtime.GOARCH, versionString) + if err != nil { return err } diff --git a/builtin/providers/google/service_scope.go b/builtin/providers/google/service_scope.go index e4d5203c6..3985a9cc9 100644 --- a/builtin/providers/google/service_scope.go +++ b/builtin/providers/google/service_scope.go @@ -8,6 +8,7 @@ func canonicalizeServiceScope(scope string) string { "compute-ro": "https://www.googleapis.com/auth/compute.readonly", "compute-rw": "https://www.googleapis.com/auth/compute", "datastore": "https://www.googleapis.com/auth/datastore", + "logging-write": "https://www.googleapis.com/auth/logging.write", "sql": "https://www.googleapis.com/auth/sqlservice", "sql-admin": "https://www.googleapis.com/auth/sqlservice.admin", "storage-full": "https://www.googleapis.com/auth/devstorage.full_control",