provider/openstack: Add Terraform version to UserAgent string (#14955)

* 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
This commit is contained in:
Gavin Williams 2017-06-02 05:12:25 +01:00 committed by Joe Topjian
parent 29444aee87
commit 401c6a95a7
2 changed files with 18 additions and 0 deletions

View File

@ -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 {
@ -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)

14
terraform/user_agent.go Normal file
View File

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