From d4f7cdc877721880c46c6d8bff726613532522b2 Mon Sep 17 00:00:00 2001 From: Lars Wander Date: Mon, 19 Oct 2015 15:38:23 -0400 Subject: [PATCH] GCP UserAgent now shows accurate Terraform version --- builtin/providers/google/config.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/builtin/providers/google/config.go b/builtin/providers/google/config.go index 6bfa3553d..1198a7c0a 100644 --- a/builtin/providers/google/config.go +++ b/builtin/providers/google/config.go @@ -10,8 +10,7 @@ import ( "runtime" "strings" - // TODO(dcunnin): Use version code from version.go - // "github.com/hashicorp/terraform" + "github.com/hashicorp/terraform/terraform" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" @@ -117,13 +116,11 @@ func (c *Config) loadAndValidate() error { } - // Build 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) - // } + versionString := terraform.Version + prerelease := terraform.VersionPrerelease + if len(prerelease) > 0 { + versionString = fmt.Sprintf("%s-%s", versionString, prerelease) + } userAgent := fmt.Sprintf( "(%s %s) Terraform/%s", runtime.GOOS, runtime.GOARCH, versionString)