Skip to content

Commit

Permalink
provider/openstack: Add Terraform version to UserAgent string (#14955)
Browse files Browse the repository at this point in the history
* core: Add 'UserAgentString' helper function to generate a standard UserAgent string. Example generation: 'Terraform 0.9.7-dev (go1.8.1)'

* provider/openstack: Add Terraform version to UserAgent string
  • Loading branch information
fatmcgav authored and jtopjian committed Jun 2, 2017
1 parent 29444ae commit 401c6a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions builtin/providers/openstack/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth"
"github.com/hashicorp/terraform/helper/pathorcontents"
"github.com/hashicorp/terraform/terraform"
)

type Config struct {
Expand Down Expand Up @@ -69,6 +70,9 @@ func (c *Config) loadAndValidate() error {
return err
}

// Set UserAgent
client.UserAgent.Prepend(terraform.UserAgentString())

config := &tls.Config{}
if c.CACertFile != "" {
caCert, _, err := pathorcontents.Read(c.CACertFile)
Expand Down
14 changes: 14 additions & 0 deletions terraform/user_agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package terraform

import (
"fmt"
"runtime"
)

// The standard Terraform User-Agent format
const UserAgent = "Terraform %s (%s)"

// Generate a UserAgent string
func UserAgentString() string {
return fmt.Sprintf(UserAgent, VersionString(), runtime.Version())
}

0 comments on commit 401c6a9

Please sign in to comment.