diff --git a/backend/local/local_test.go b/backend/local/local_test.go index 70c25e24e..852390237 100644 --- a/backend/local/local_test.go +++ b/backend/local/local_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) func TestMain(m *testing.M) { diff --git a/backend/remote-state/azure/sender.go b/backend/remote-state/azure/sender.go index d2b432a65..958273e83 100644 --- a/backend/remote-state/azure/sender.go +++ b/backend/remote-state/azure/sender.go @@ -6,7 +6,7 @@ import ( "net/http/httputil" "github.com/Azure/go-autorest/autorest" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) func buildSender() autorest.Sender { diff --git a/backend/remote-state/inmem/backend_test.go b/backend/remote-state/inmem/backend_test.go index a6ac0694e..ecaab0da7 100644 --- a/backend/remote-state/inmem/backend_test.go +++ b/backend/remote-state/inmem/backend_test.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" statespkg "github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/states/remote" ) diff --git a/backend/remote-state/s3/backend.go b/backend/remote-state/s3/backend.go index 1ccee3207..b656e3953 100644 --- a/backend/remote-state/s3/backend.go +++ b/backend/remote-state/s3/backend.go @@ -12,8 +12,8 @@ import ( "github.com/aws/aws-sdk-go/service/s3" awsbase "github.com/hashicorp/aws-sdk-go-base" "github.com/hashicorp/terraform/backend" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/version" ) diff --git a/backend/remote/remote_test.go b/backend/remote/remote_test.go index 7fc332e49..c164cb815 100644 --- a/backend/remote/remote_test.go +++ b/backend/remote/remote_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) func TestMain(m *testing.M) { diff --git a/command/command_test.go b/command/command_test.go index 336972cd6..8ef664ba9 100644 --- a/command/command_test.go +++ b/command/command_test.go @@ -29,8 +29,8 @@ import ( "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/configs/configschema" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/internal/copy" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/plans" "github.com/hashicorp/terraform/plans/planfile" "github.com/hashicorp/terraform/providers" diff --git a/dag/dag_test.go b/dag/dag_test.go index ebf5537b6..898c035b4 100644 --- a/dag/dag_test.go +++ b/dag/dag_test.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform/tfdiags" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) func TestMain(m *testing.M) { diff --git a/helper/logging/transport.go b/helper/logging/transport.go deleted file mode 100644 index bddabe647..000000000 --- a/helper/logging/transport.go +++ /dev/null @@ -1,70 +0,0 @@ -package logging - -import ( - "bytes" - "encoding/json" - "log" - "net/http" - "net/http/httputil" - "strings" -) - -type transport struct { - name string - transport http.RoundTripper -} - -func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) { - if IsDebugOrHigher() { - reqData, err := httputil.DumpRequestOut(req, true) - if err == nil { - log.Printf("[DEBUG] "+logReqMsg, t.name, prettyPrintJsonLines(reqData)) - } else { - log.Printf("[ERROR] %s API Request error: %#v", t.name, err) - } - } - - resp, err := t.transport.RoundTrip(req) - if err != nil { - return resp, err - } - - if IsDebugOrHigher() { - respData, err := httputil.DumpResponse(resp, true) - if err == nil { - log.Printf("[DEBUG] "+logRespMsg, t.name, prettyPrintJsonLines(respData)) - } else { - log.Printf("[ERROR] %s API Response error: %#v", t.name, err) - } - } - - return resp, nil -} - -func NewTransport(name string, t http.RoundTripper) *transport { - return &transport{name, t} -} - -// prettyPrintJsonLines iterates through a []byte line-by-line, -// transforming any lines that are complete json into pretty-printed json. -func prettyPrintJsonLines(b []byte) string { - parts := strings.Split(string(b), "\n") - for i, p := range parts { - if b := []byte(p); json.Valid(b) { - var out bytes.Buffer - json.Indent(&out, b, "", " ") - parts[i] = out.String() - } - } - return strings.Join(parts, "\n") -} - -const logReqMsg = `%s API Request Details: ----[ REQUEST ]--------------------------------------- -%s ------------------------------------------------------` - -const logRespMsg = `%s API Response Details: ----[ RESPONSE ]-------------------------------------- -%s ------------------------------------------------------` diff --git a/helper/resource/testing.go b/helper/resource/testing.go index cd77bad04..5b9ccee29 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -24,8 +24,8 @@ import ( "github.com/hashicorp/terraform/command/format" "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs/configload" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/internal/initwd" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/terraform" diff --git a/internal/getproviders/http_mirror_source.go b/internal/getproviders/http_mirror_source.go index 71cc79efa..ca703b627 100644 --- a/internal/getproviders/http_mirror_source.go +++ b/internal/getproviders/http_mirror_source.go @@ -18,8 +18,8 @@ import ( "golang.org/x/net/idna" "github.com/hashicorp/terraform/addrs" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/version" ) diff --git a/internal/getproviders/registry_client.go b/internal/getproviders/registry_client.go index 8c0256661..1af060e56 100644 --- a/internal/getproviders/registry_client.go +++ b/internal/getproviders/registry_client.go @@ -21,8 +21,8 @@ import ( svcauth "github.com/hashicorp/terraform-svchost/auth" "github.com/hashicorp/terraform/addrs" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/version" ) diff --git a/internal/initwd/module_install_test.go b/internal/initwd/module_install_test.go index f84d01f0b..9eba2fb79 100644 --- a/internal/initwd/module_install_test.go +++ b/internal/initwd/module_install_test.go @@ -14,8 +14,8 @@ import ( version "github.com/hashicorp/go-version" "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs/configload" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/internal/copy" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/registry" "github.com/hashicorp/terraform/tfdiags" ) diff --git a/helper/logging/indent.go b/internal/logging/indent.go similarity index 100% rename from helper/logging/indent.go rename to internal/logging/indent.go diff --git a/helper/logging/indent_test.go b/internal/logging/indent_test.go similarity index 100% rename from helper/logging/indent_test.go rename to internal/logging/indent_test.go diff --git a/helper/logging/level.go b/internal/logging/level.go similarity index 100% rename from helper/logging/level.go rename to internal/logging/level.go diff --git a/helper/logging/level_test.go b/internal/logging/level_test.go similarity index 100% rename from helper/logging/level_test.go rename to internal/logging/level_test.go diff --git a/helper/logging/logging.go b/internal/logging/logging.go similarity index 100% rename from helper/logging/logging.go rename to internal/logging/logging.go diff --git a/main.go b/main.go index 86588bd1a..28e8b169a 100644 --- a/main.go +++ b/main.go @@ -18,8 +18,8 @@ import ( "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/command/cliconfig" "github.com/hashicorp/terraform/command/format" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/version" "github.com/mattn/go-colorable" "github.com/mattn/go-shellwords" diff --git a/registry/client.go b/registry/client.go index 61c89c65a..b8372b48f 100644 --- a/registry/client.go +++ b/registry/client.go @@ -16,8 +16,8 @@ import ( "github.com/hashicorp/go-retryablehttp" svchost "github.com/hashicorp/terraform-svchost" "github.com/hashicorp/terraform-svchost/disco" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/httpclient" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/registry/regsrc" "github.com/hashicorp/terraform/registry/response" "github.com/hashicorp/terraform/version" diff --git a/repl/session_test.go b/repl/session_test.go index a49708276..0ff59e828 100644 --- a/repl/session_test.go +++ b/repl/session_test.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/configs/configschema" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/internal/initwd" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/states" "github.com/hashicorp/terraform/terraform" diff --git a/states/statemgr/statemgr_test.go b/states/statemgr/statemgr_test.go index 62625780f..c22b6a6ba 100644 --- a/states/statemgr/statemgr_test.go +++ b/states/statemgr/statemgr_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) func TestNewLockInfo(t *testing.T) { diff --git a/terraform/graph_builder.go b/terraform/graph_builder.go index f631f83b5..7d4bd88b6 100644 --- a/terraform/graph_builder.go +++ b/terraform/graph_builder.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/hashicorp/terraform/addrs" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/tfdiags" ) diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 94e5a5113..31e410000 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -19,8 +19,8 @@ import ( "github.com/hashicorp/terraform/configs" "github.com/hashicorp/terraform/configs/configload" "github.com/hashicorp/terraform/helper/experiment" - "github.com/hashicorp/terraform/helper/logging" "github.com/hashicorp/terraform/internal/initwd" + "github.com/hashicorp/terraform/internal/logging" "github.com/hashicorp/terraform/plans" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/provisioners" diff --git a/terraform/transform.go b/terraform/transform.go index d587c89e4..dc615f2b1 100644 --- a/terraform/transform.go +++ b/terraform/transform.go @@ -4,7 +4,7 @@ import ( "log" "github.com/hashicorp/terraform/dag" - "github.com/hashicorp/terraform/helper/logging" + "github.com/hashicorp/terraform/internal/logging" ) // GraphTransformer is the interface that transformers implement. This