From ec3feff9cae071d43f37d1db86eaa7248e075af3 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 --- config.go | 14 ++++++++++++++ service_scope.go | 1 + 2 files changed, 15 insertions(+) diff --git a/config.go b/config.go index 254cb3eb..f9a58485 100644 --- a/config.go +++ b/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/service_scope.go b/service_scope.go index e4d5203c..3985a9cc 100644 --- a/service_scope.go +++ b/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",