Add a UserAgent with version temporarily set to 0.0.0

This commit is contained in:
Dave Cunningham 2015-04-15 18:17:21 -04:00
parent c4de508293
commit e0905d89f8
2 changed files with 15 additions and 0 deletions

View File

@ -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
}

View File

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