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",