diff --git a/backend/init/init.go b/backend/init/init.go index 8f70a1f81..5142c4193 100644 --- a/backend/init/init.go +++ b/backend/init/init.go @@ -5,8 +5,8 @@ package init import ( "sync" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/tfdiags" "github.com/zclconf/go-cty/cty" diff --git a/backend/remote/backend.go b/backend/remote/backend.go index c8bc867e7..a65c1d3cf 100644 --- a/backend/remote/backend.go +++ b/backend/remote/backend.go @@ -14,12 +14,12 @@ import ( tfe "github.com/hashicorp/go-tfe" version "github.com/hashicorp/go-version" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/configs/configschema" "github.com/hashicorp/terraform/state" "github.com/hashicorp/terraform/state/remote" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/tfdiags" tfversion "github.com/hashicorp/terraform/version" diff --git a/backend/remote/backend_test.go b/backend/remote/backend_test.go index ac3fd01eb..2f9edbc61 100644 --- a/backend/remote/backend_test.go +++ b/backend/remote/backend_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/version" "github.com/zclconf/go-cty/cty" diff --git a/backend/remote/testing.go b/backend/remote/testing.go index 11197487a..d7706fe19 100644 --- a/backend/remote/testing.go +++ b/backend/remote/testing.go @@ -10,16 +10,18 @@ import ( "testing" tfe "github.com/hashicorp/go-tfe" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/auth" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs/configschema" + "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/state/remote" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/auth" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/tfdiags" + "github.com/hashicorp/terraform/version" "github.com/mitchellh/cli" "github.com/zclconf/go-cty/cty" @@ -268,6 +270,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.ForceHostServices(svchost.Hostname(defaultHostname), services) d.ForceHostServices(svchost.Hostname("localhost"), services) diff --git a/command/cliconfig/cliconfig.go b/command/cliconfig/cliconfig.go index 5925b40b3..ea0bf1e57 100644 --- a/command/cliconfig/cliconfig.go +++ b/command/cliconfig/cliconfig.go @@ -17,7 +17,7 @@ import ( "github.com/hashicorp/hcl" - "github.com/hashicorp/terraform/svchost" + "github.com/hashicorp/terraform-svchost" "github.com/hashicorp/terraform/tfdiags" ) diff --git a/command/cliconfig/credentials.go b/command/cliconfig/credentials.go index d23ede4b6..907978407 100644 --- a/command/cliconfig/credentials.go +++ b/command/cliconfig/credentials.go @@ -12,10 +12,10 @@ import ( "github.com/zclconf/go-cty/cty" ctyjson "github.com/zclconf/go-cty/cty/json" + "github.com/hashicorp/terraform-svchost" + svcauth "github.com/hashicorp/terraform-svchost/auth" "github.com/hashicorp/terraform/configs/hcl2shim" pluginDiscovery "github.com/hashicorp/terraform/plugin/discovery" - "github.com/hashicorp/terraform/svchost" - svcauth "github.com/hashicorp/terraform/svchost/auth" ) // credentialsConfigFile returns the path for the special configuration file diff --git a/command/cliconfig/credentials_test.go b/command/cliconfig/credentials_test.go index 3cb0212f0..22a9e3f83 100644 --- a/command/cliconfig/credentials_test.go +++ b/command/cliconfig/credentials_test.go @@ -10,8 +10,8 @@ import ( "github.com/google/go-cmp/cmp" "github.com/zclconf/go-cty/cty" - "github.com/hashicorp/terraform/svchost" - svcauth "github.com/hashicorp/terraform/svchost/auth" + "github.com/hashicorp/terraform-svchost" + svcauth "github.com/hashicorp/terraform-svchost/auth" ) func TestCredentialsForHost(t *testing.T) { diff --git a/command/login.go b/command/login.go index 527d43643..28092ea8c 100644 --- a/command/login.go +++ b/command/login.go @@ -13,11 +13,11 @@ import ( "path/filepath" "strings" + "github.com/hashicorp/terraform-svchost" + svcauth "github.com/hashicorp/terraform-svchost/auth" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/command/cliconfig" "github.com/hashicorp/terraform/httpclient" - "github.com/hashicorp/terraform/svchost" - svcauth "github.com/hashicorp/terraform/svchost/auth" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/tfdiags" uuid "github.com/hashicorp/go-uuid" diff --git a/command/login_test.go b/command/login_test.go index 33d68cb5a..d02a7becd 100644 --- a/command/login_test.go +++ b/command/login_test.go @@ -12,11 +12,13 @@ import ( "github.com/mitchellh/cli" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/command/cliconfig" oauthserver "github.com/hashicorp/terraform/command/testdata/login-oauth-server" "github.com/hashicorp/terraform/command/webbrowser" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/disco" + "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/version" ) func TestLogin(t *testing.T) { @@ -43,6 +45,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())) inputBuf := &bytes.Buffer{} ui.InputReader = inputBuf diff --git a/command/meta.go b/command/meta.go index 6399c8c45..854cc954b 100644 --- a/command/meta.go +++ b/command/meta.go @@ -14,6 +14,7 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/backend" "github.com/hashicorp/terraform/backend/local" @@ -24,7 +25,6 @@ import ( "github.com/hashicorp/terraform/helper/wrappedstreams" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/provisioners" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/tfdiags" "github.com/mitchellh/cli" diff --git a/commands.go b/commands.go index fffbb3639..b72c5e856 100644 --- a/commands.go +++ b/commands.go @@ -6,13 +6,13 @@ import ( "github.com/mitchellh/cli" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/auth" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/command" "github.com/hashicorp/terraform/command/cliconfig" "github.com/hashicorp/terraform/command/webbrowser" pluginDiscovery "github.com/hashicorp/terraform/plugin/discovery" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/auth" - "github.com/hashicorp/terraform/svchost/disco" ) // runningInAutomationEnvName gives the name of an environment variable that diff --git a/configs/configload/loader.go b/configs/configload/loader.go index 416b48fc8..a09b80c8c 100644 --- a/configs/configload/loader.go +++ b/configs/configload/loader.go @@ -4,9 +4,9 @@ import ( "fmt" "path/filepath" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/registry" - "github.com/hashicorp/terraform/svchost/disco" "github.com/spf13/afero" ) diff --git a/configs/configload/module_mgr.go b/configs/configload/module_mgr.go index 3c410eeb7..16871e310 100644 --- a/configs/configload/module_mgr.go +++ b/configs/configload/module_mgr.go @@ -4,9 +4,9 @@ import ( "os" "path/filepath" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/internal/modsdir" "github.com/hashicorp/terraform/registry" - "github.com/hashicorp/terraform/svchost/disco" "github.com/spf13/afero" ) diff --git a/main.go b/main.go index 3cc867801..628e1447d 100644 --- a/main.go +++ b/main.go @@ -12,9 +12,11 @@ import ( "sync" "github.com/hashicorp/go-plugin" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/command/format" "github.com/hashicorp/terraform/helper/logging" - "github.com/hashicorp/terraform/svchost/disco" + "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/version" "github.com/mattn/go-colorable" "github.com/mattn/go-shellwords" "github.com/mitchellh/cli" @@ -159,6 +161,7 @@ func wrappedMain() int { // object checks that and just acts as though no credentials are present. } services := disco.NewWithCredentialsSource(credsSrc) + services.SetUserAgent(httpclient.TerraformUserAgent(version.String())) // Initialize the backends. backendInit.Init(services) diff --git a/plugin/discovery/get.go b/plugin/discovery/get.go index 7724cc54b..0ee23c6fd 100644 --- a/plugin/discovery/get.go +++ b/plugin/discovery/get.go @@ -16,12 +16,12 @@ import ( "github.com/hashicorp/errwrap" getter "github.com/hashicorp/go-getter" multierror "github.com/hashicorp/go-multierror" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/tfdiags" tfversion "github.com/hashicorp/terraform/version" "github.com/mitchellh/cli" diff --git a/plugin/discovery/get_test.go b/plugin/discovery/get_test.go index b14de9f74..2253a1c35 100644 --- a/plugin/discovery/get_test.go +++ b/plugin/discovery/get_test.go @@ -17,11 +17,13 @@ import ( "strings" "testing" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/addrs" + "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry" "github.com/hashicorp/terraform/registry/response" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/disco" + "github.com/hashicorp/terraform/version" "github.com/mitchellh/cli" ) @@ -741,6 +743,7 @@ func Disco(s *httptest.Server) *disco.Disco { "providers.v1": fmt.Sprintf("%s/v1/providers", s.URL), } d := disco.New() + d.SetUserAgent(httpclient.TerraformUserAgent(version.String())) d.ForceHostServices(svchost.Hostname("registry.terraform.io"), services) d.ForceHostServices(svchost.Hostname("localhost"), services) diff --git a/registry/client.go b/registry/client.go index 93424d176..e8f7ac111 100644 --- a/registry/client.go +++ b/registry/client.go @@ -11,11 +11,11 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/version" ) @@ -52,6 +52,8 @@ func NewClient(services *disco.Disco, client *http.Client) *Client { services.Transport = client.Transport + services.SetUserAgent(httpclient.TerraformUserAgent(version.String())) + return &Client{ client: client, services: services, diff --git a/registry/client_test.go b/registry/client_test.go index fd39f9f75..105205f94 100644 --- a/registry/client_test.go +++ b/registry/client_test.go @@ -7,9 +7,11 @@ import ( "testing" version "github.com/hashicorp/go-version" + "github.com/hashicorp/terraform-svchost/disco" + "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/test" - "github.com/hashicorp/terraform/svchost/disco" + tfversion "github.com/hashicorp/terraform/version" ) func TestLookupModuleVersions(t *testing.T) { @@ -136,6 +138,7 @@ func TestAccLookupModuleVersions(t *testing.T) { t.Skip() } regDisco := disco.New() + regDisco.SetUserAgent(httpclient.TerraformUserAgent(tfversion.String())) // test with and without a hostname for _, src := range []string{ diff --git a/registry/errors.go b/registry/errors.go index 5a6a31b08..3b99b34d8 100644 --- a/registry/errors.go +++ b/registry/errors.go @@ -3,8 +3,8 @@ package registry import ( "fmt" + "github.com/hashicorp/terraform-svchost/disco" "github.com/hashicorp/terraform/registry/regsrc" - "github.com/hashicorp/terraform/svchost/disco" ) type errModuleNotFound struct { diff --git a/registry/regsrc/friendly_host.go b/registry/regsrc/friendly_host.go index 14b4dce9c..c9bc40bee 100644 --- a/registry/regsrc/friendly_host.go +++ b/registry/regsrc/friendly_host.go @@ -4,7 +4,7 @@ import ( "regexp" "strings" - "github.com/hashicorp/terraform/svchost" + "github.com/hashicorp/terraform-svchost" ) var ( diff --git a/registry/regsrc/module.go b/registry/regsrc/module.go index 325706ec2..c3edd7d87 100644 --- a/registry/regsrc/module.go +++ b/registry/regsrc/module.go @@ -6,7 +6,7 @@ import ( "regexp" "strings" - "github.com/hashicorp/terraform/svchost" + "github.com/hashicorp/terraform-svchost" ) var ( diff --git a/registry/regsrc/terraform_provider.go b/registry/regsrc/terraform_provider.go index 58dedee5e..7205d03b8 100644 --- a/registry/regsrc/terraform_provider.go +++ b/registry/regsrc/terraform_provider.go @@ -5,7 +5,7 @@ import ( "runtime" "strings" - "github.com/hashicorp/terraform/svchost" + "github.com/hashicorp/terraform-svchost" ) var ( diff --git a/registry/test/mock_registry.go b/registry/test/mock_registry.go index f89cfc016..e1b6249e3 100644 --- a/registry/test/mock_registry.go +++ b/registry/test/mock_registry.go @@ -12,11 +12,13 @@ import ( "strings" version "github.com/hashicorp/go-version" + "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform-svchost/auth" + "github.com/hashicorp/terraform-svchost/disco" + "github.com/hashicorp/terraform/httpclient" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" - "github.com/hashicorp/terraform/svchost" - "github.com/hashicorp/terraform/svchost/auth" - "github.com/hashicorp/terraform/svchost/disco" + tfversion "github.com/hashicorp/terraform/version" ) // Disco return a *disco.Disco mapping registry.terraform.io, localhost, @@ -29,6 +31,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.ForceHostServices(svchost.Hostname("registry.terraform.io"), services) d.ForceHostServices(svchost.Hostname("localhost"), services)