From 0b32f5eaf213222dee8615b3daa8c4809c9bade8 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Thu, 16 Nov 2017 23:29:26 +0100 Subject: [PATCH] Add HTTP transport debugging using terraform's helper (#50) --- pagerduty/config.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pagerduty/config.go b/pagerduty/config.go index e70d5d559..c2fd06ea1 100644 --- a/pagerduty/config.go +++ b/pagerduty/config.go @@ -3,6 +3,7 @@ package pagerduty import ( "fmt" "log" + "net/http" "runtime" "github.com/hashicorp/terraform/helper/logging" @@ -33,10 +34,15 @@ func (c *Config) Client() (*pagerduty.Client, error) { return nil, fmt.Errorf(invalidCreds) } + var httpClient *http.Client + httpClient = http.DefaultClient + httpClient.Transport = logging.NewTransport("PagerDuty", http.DefaultTransport) + config := &pagerduty.Config{ - Debug: logging.IsDebugOrHigher(), - Token: c.Token, - UserAgent: fmt.Sprintf("(%s %s) Terraform/%s", runtime.GOOS, runtime.GOARCH, terraform.VersionString()), + Debug: logging.IsDebugOrHigher(), + HTTPClient: httpClient, + Token: c.Token, + UserAgent: fmt.Sprintf("(%s %s) Terraform/%s", runtime.GOOS, runtime.GOARCH, terraform.VersionString()), } client, err := pagerduty.NewClient(config)