mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
update to use const opentf
This commit is contained in:
parent
d1b585bab6
commit
5c74d466ce
@ -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)
|
||||
|
@ -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()},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user