mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
export more commons
This commit is contained in:
parent
7078034160
commit
7723d93946
@ -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.TerraformUA, TerraformVersion)
|
||||
locationClient.AppendUserAgent(httpclient.OpenTFUserAgent, 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)
|
||||
|
@ -6,6 +6,7 @@ package s3
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/placeholderplaceholderplaceholder/opentf/internal/httpclient"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -394,8 +395,8 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
|
||||
Token: stringAttr(obj, "token"),
|
||||
UserAgentProducts: []*awsbase.UserAgentProduct{
|
||||
{Name: "APN", Version: "1.0"},
|
||||
{Name: "placeholderplaceholderplaceholder", Version: "1.0"},
|
||||
{Name: "OpenTF", Version: version.String()},
|
||||
{Name: httpclient.OpenTFUserAgent, Version: "1.0"},
|
||||
{Name: httpclient.Organization, Version: version.String()},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,12 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const uaEnvVar = "TF_APPEND_USER_AGENT"
|
||||
const TerraformUA = "placeholderplaceholderplaceholder-OpenTF"
|
||||
const (
|
||||
uaEnvVar = "TF_APPEND_USER_AGENT"
|
||||
Organization = "placeholderplaceholderplaceholder"
|
||||
Application = "OpenTF"
|
||||
OpenTFUserAgent = Organization + "-" + Application
|
||||
)
|
||||
|
||||
type userAgentRoundTripper struct {
|
||||
inner http.RoundTripper
|
||||
@ -28,7 +32,7 @@ func (rt *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, e
|
||||
}
|
||||
|
||||
func TerraformUserAgent(version string) string {
|
||||
ua := fmt.Sprintf("%s/%s (+https://www.opentf.org)", TerraformUA, version)
|
||||
ua := fmt.Sprintf("%s/%s (+https://www.opentf.org)", OpenTFUserAgent, version)
|
||||
|
||||
if add := os.Getenv(uaEnvVar); add != "" {
|
||||
add = strings.TrimSpace(add)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUserAgentString_env(t *testing.T) {
|
||||
expectedBase := fmt.Sprintf("%s/%s (+https://www.opentf.org)", TerraformUA, version.Version)
|
||||
expectedBase := fmt.Sprintf("%s/%s (+https://www.opentf.org)", OpenTFUserAgent, version.Version)
|
||||
if oldenv, isSet := os.LookupEnv(uaEnvVar); isSet {
|
||||
defer os.Setenv(uaEnvVar, oldenv)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user