rename func

This commit is contained in:
Elbaz 2023-08-27 17:38:54 +03:00
parent b4a1e86ec6
commit 9362df1d9e
15 changed files with 18 additions and 18 deletions

View File

@ -238,7 +238,7 @@ func (c *ArmClient) configureClient(client *autorest.Client, auth autorest.Autho
}
func buildUserAgent() string {
userAgent := httpclient.TerraformUserAgent(version.Version)
userAgent := httpclient.OpenTfUserAgent(version.Version)
// append the CloudShell version to the user agent if it exists
if azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT"); azureAgent != "" {

View File

@ -208,7 +208,7 @@ func (b *Backend) configure(ctx context.Context) error {
opts = append(opts, credOptions...)
}
opts = append(opts, option.WithUserAgent(httpclient.TerraformUserAgent(version.Version)))
opts = append(opts, option.WithUserAgent(httpclient.OpenTfUserAgent(version.Version)))
// Custom endpoint for storage API
if storageEndpoint, ok := data.GetOk("storage_custom_endpoint"); ok {

View File

@ -439,7 +439,7 @@ func testGetClientOptions(t *testing.T) ([]option.ClientOption, error) {
}
credOptions = append(credOptions, option.WithCredentialsJSON([]byte(contents)))
opts = append(opts, credOptions...)
opts = append(opts, option.WithUserAgent(httpclient.TerraformUserAgent(version.Version)))
opts = append(opts, option.WithUserAgent(httpclient.OpenTfUserAgent(version.Version)))
return opts, nil
}

View File

@ -243,7 +243,7 @@ func (b *Backend) configure(ctx context.Context) error {
}
// Overriding with static configuration
cfg.UserAgent = httpclient.TerraformUserAgent(version.Version)
cfg.UserAgent = httpclient.OpenTfUserAgent(version.Version)
if v, ok := data.GetOk("host"); ok {
cfg.Host = v.(string)

View File

@ -405,7 +405,7 @@ func (b *Backend) configure(ctx context.Context) error {
if securityToken != "" {
options = append(options, oss.SecurityToken(securityToken))
}
options = append(options, oss.UserAgent(httpclient.TerraformUserAgent(TerraformVersion)))
options = append(options, oss.UserAgent(httpclient.OpenTfUserAgent(TerraformVersion)))
proxyUrl := getHttpProxyUrl()
if proxyUrl != nil {

View File

@ -295,7 +295,7 @@ func testDisco(s *httptest.Server) *disco.Disco {
"versions.v1": fmt.Sprintf("%s/v1/versions/", s.URL),
}
d := disco.NewWithCredentialsSource(credsSrc)
d.SetUserAgent(httpclient.TerraformUserAgent(version.String()))
d.SetUserAgent(httpclient.OpenTfUserAgent(version.String()))
d.ForceHostServices(svchost.Hostname(defaultHostname), services)
d.ForceHostServices(svchost.Hostname("localhost"), services)

View File

@ -579,7 +579,7 @@ func testDisco(s *httptest.Server) *disco.Disco {
"tfe.v2": fmt.Sprintf("%s/api/v2/", s.URL),
}
d := disco.NewWithCredentialsSource(credsSrc)
d.SetUserAgent(httpclient.TerraformUserAgent(version.String()))
d.SetUserAgent(httpclient.OpenTfUserAgent(version.String()))
d.ForceHostServices(svchost.Hostname(defaultHostname), services)
d.ForceHostServices(svchost.Hostname("localhost"), services)

View File

@ -52,7 +52,7 @@ func TestLogin(t *testing.T) {
browserLauncher := webbrowser.NewMockLauncher(ctx)
creds := cliconfig.EmptyCredentialsSourceForTests(filepath.Join(workDir, "credentials.tfrc.json"))
svcs := disco.NewWithCredentialsSource(creds)
svcs.SetUserAgent(httpclient.TerraformUserAgent(version.String()))
svcs.SetUserAgent(httpclient.OpenTfUserAgent(version.String()))
svcs.ForceHostServices(svchost.Hostname("example.com"), map[string]interface{}{
"login.v1": map[string]interface{}{

View File

@ -15,7 +15,7 @@ import (
func New() *http.Client {
cli := cleanhttp.DefaultPooledClient()
cli.Transport = &userAgentRoundTripper{
userAgent: TerraformUserAgent(version.Version),
userAgent: OpenTfUserAgent(version.Version),
inner: cli.Transport,
}
return cli

View File

@ -37,7 +37,7 @@ func Application() string {
return defaultApplicationName
}
func TerraformUserAgent(version string) string {
func OpenTfUserAgent(version string) string {
ua := fmt.Sprintf("%s/%s", defaultApplicationName, version)
if customUa := os.Getenv(customUaEnvVar); customUa != "" {
ua = customUa

View File

@ -39,7 +39,7 @@ func TestUserAgentString_env(t *testing.T) {
os.Setenv(appendUaEnvVar, c.additional)
}
actual := TerraformUserAgent(version.Version)
actual := OpenTfUserAgent(version.Version)
if c.expected != actual {
t.Fatalf("Expected User-Agent '%s' does not match '%s'", c.expected, actual)
@ -72,7 +72,7 @@ func TestUserAgentAppendViaEnvVar(t *testing.T) {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
os.Unsetenv(appendUaEnvVar)
os.Setenv(appendUaEnvVar, tc.envVarValue)
givenUA := TerraformUserAgent("0.0.0")
givenUA := OpenTfUserAgent("0.0.0")
if givenUA != tc.expected {
t.Fatalf("Expected User-Agent '%s' does not match '%s'", tc.expected, givenUA)
}
@ -99,7 +99,7 @@ func TestCustomUserAgentViaEnvVar(t *testing.T) {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
os.Unsetenv(customUaEnvVar)
os.Setenv(customUaEnvVar, tc.envVarValue)
givenUA := TerraformUserAgent("0.0.0")
givenUA := OpenTfUserAgent("0.0.0")
if givenUA != tc.envVarValue {
t.Fatalf("Expected User-Agent '%s' does not match '%s'", tc.envVarValue, givenUA)
}
@ -136,7 +136,7 @@ func TestCustomUserAgentAndAppendViaEnvVar(t *testing.T) {
os.Unsetenv(appendUaEnvVar)
os.Setenv(customUaEnvVar, tc.customUaValue)
os.Setenv(appendUaEnvVar, tc.appendUaValue)
givenUA := TerraformUserAgent("0.0.0")
givenUA := OpenTfUserAgent("0.0.0")
if givenUA != tc.expected {
t.Fatalf("Expected User-Agent '%s' does not match '%s'", tc.expected, givenUA)
}

View File

@ -92,7 +92,7 @@ func NewClient(services *disco.Disco, client *http.Client) *Client {
services.Transport = retryableClient.HTTPClient.Transport
services.SetUserAgent(httpclient.TerraformUserAgent(version.String()))
services.SetUserAgent(httpclient.OpenTfUserAgent(version.String()))
return &Client{
client: retryableClient,

View File

@ -214,7 +214,7 @@ func TestAccLookupModuleVersions(t *testing.T) {
t.Skip()
}
regDisco := disco.New()
regDisco.SetUserAgent(httpclient.TerraformUserAgent(tfversion.String()))
regDisco.SetUserAgent(httpclient.OpenTfUserAgent(tfversion.String()))
// test with and without a hostname
for _, src := range []string{

View File

@ -29,7 +29,7 @@ func Disco(s *httptest.Server) *disco.Disco {
"providers.v1": fmt.Sprintf("%s/v1/providers", s.URL),
}
d := disco.NewWithCredentialsSource(credsSrc)
d.SetUserAgent(httpclient.TerraformUserAgent(tfversion.String()))
d.SetUserAgent(httpclient.OpenTfUserAgent(tfversion.String()))
d.ForceHostServices(svchost.Hostname("registry.terraform.io"), services)
d.ForceHostServices(svchost.Hostname("localhost"), services)

View File

@ -181,7 +181,7 @@ func realMain() int {
// object checks that and just acts as though no credentials are present.
services = disco.NewWithCredentialsSource(nil)
}
services.SetUserAgent(httpclient.TerraformUserAgent(version.String()))
services.SetUserAgent(httpclient.OpenTfUserAgent(version.String()))
providerSrc, diags := providerSource(config.ProviderInstallation, services)
if len(diags) > 0 {