update to use const opentf

This commit is contained in:
Elbaz 2023-08-28 11:35:51 +03:00
parent d1b585bab6
commit 5c74d466ce
4 changed files with 6 additions and 6 deletions

View File

@ -439,7 +439,7 @@ func (b *Backend) getOSSEndpointByRegion(access_key, secret_key, security_token,
return nil, fmt.Errorf("unable to initialize the location client: %#v", err)
}
locationClient.AppendUserAgent(httpclient.UserAgentApplication(), TerraformVersion)
locationClient.AppendUserAgent(httpclient.DefaultApplicationName, TerraformVersion)
endpointsResponse, err := locationClient.DescribeEndpoints(args)
if err != nil {
return nil, fmt.Errorf("describe oss endpoint using region: %#v got an error: %#v", region, err)

View File

@ -395,7 +395,7 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
Token: stringAttr(obj, "token"),
UserAgentProducts: []*awsbase.UserAgentProduct{
{Name: "APN", Version: "1.0"},
{Name: httpclient.UserAgentApplication(), Version: version.String()},
{Name: httpclient.DefaultApplicationName, Version: version.String()},
},
}

View File

@ -14,7 +14,7 @@ import (
const (
appendUaEnvVar = "TF_APPEND_USER_AGENT"
customUaEnvVar = "OPENTF_USER_AGENT"
defaultApplicationName = "OpenTF"
DefaultApplicationName = "OpenTF"
)
type userAgentRoundTripper struct {
@ -34,11 +34,11 @@ func UserAgentApplication() string {
if customApplication := os.Getenv(customUaEnvVar); customApplication != "" {
return customApplication
}
return defaultApplicationName
return DefaultApplicationName
}
func OpenTfUserAgent(version string) string {
ua := fmt.Sprintf("%s/%s", defaultApplicationName, version)
ua := fmt.Sprintf("%s/%s", DefaultApplicationName, version)
if customUa := os.Getenv(customUaEnvVar); customUa != "" {
ua = customUa
log.Printf("[DEBUG] Using Custom User-Agent: %s", ua)

View File

@ -12,7 +12,7 @@ import (
)
func TestUserAgentString_env(t *testing.T) {
expectedBase := fmt.Sprintf("%s/%s", defaultApplicationName, version.Version)
expectedBase := fmt.Sprintf("%s/%s", DefaultApplicationName, version.Version)
if oldenv, isSet := os.LookupEnv(appendUaEnvVar); isSet {
defer os.Setenv(appendUaEnvVar, oldenv)
} else {