Merge pull request #1547 from sparkprime/user-agent

Add a UserAgent with version temporarily set to 0.0.0
This commit is contained in:
Paul Hinze 2015-04-16 16:57:10 -05:00
commit a6325ad18c
2 changed files with 15 additions and 0 deletions

View File

@ -6,7 +6,10 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"runtime"
// TODO(dcunnin): Use version code from version.go
// "github.com/hashicorp/terraform"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
"golang.org/x/oauth2/jwt" "golang.org/x/oauth2/jwt"
@ -83,6 +86,17 @@ func (c *Config) loadAndValidate() error {
log.Printf("[INFO] Instantiating GCE client...") log.Printf("[INFO] Instantiating GCE client...")
var err error var err error
c.clientCompute, err = compute.New(client) 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 { if err != nil {
return err return err
} }

View File

@ -8,6 +8,7 @@ func canonicalizeServiceScope(scope string) string {
"compute-ro": "https://www.googleapis.com/auth/compute.readonly", "compute-ro": "https://www.googleapis.com/auth/compute.readonly",
"compute-rw": "https://www.googleapis.com/auth/compute", "compute-rw": "https://www.googleapis.com/auth/compute",
"datastore": "https://www.googleapis.com/auth/datastore", "datastore": "https://www.googleapis.com/auth/datastore",
"logging-write": "https://www.googleapis.com/auth/logging.write",
"sql": "https://www.googleapis.com/auth/sqlservice", "sql": "https://www.googleapis.com/auth/sqlservice",
"sql-admin": "https://www.googleapis.com/auth/sqlservice.admin", "sql-admin": "https://www.googleapis.com/auth/sqlservice.admin",
"storage-full": "https://www.googleapis.com/auth/devstorage.full_control", "storage-full": "https://www.googleapis.com/auth/devstorage.full_control",