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:
parent
29444aee87
commit
401c6a95a7
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/gophercloud/gophercloud/openstack"
|
"github.com/gophercloud/gophercloud/openstack"
|
||||||
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth"
|
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth"
|
||||||
"github.com/hashicorp/terraform/helper/pathorcontents"
|
"github.com/hashicorp/terraform/helper/pathorcontents"
|
||||||
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -69,6 +70,9 @@ func (c *Config) loadAndValidate() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set UserAgent
|
||||||
|
client.UserAgent.Prepend(terraform.UserAgentString())
|
||||||
|
|
||||||
config := &tls.Config{}
|
config := &tls.Config{}
|
||||||
if c.CACertFile != "" {
|
if c.CACertFile != "" {
|
||||||
caCert, _, err := pathorcontents.Read(c.CACertFile)
|
caCert, _, err := pathorcontents.Read(c.CACertFile)
|
||||||
|
|
|
@ -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())
|
||||||
|
}
|
Loading…
Reference in New Issue