Skip to content

Commit

Permalink
command/debug: copy api.defaultHttpClient in here
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin committed Aug 11, 2020
1 parent cbd0cb7 commit a7cb497
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions command/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/tar"
"compress/gzip"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"html/template"
Expand All @@ -18,6 +19,7 @@ import (
"syscall"
"time"

"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/nomad/api"
"github.com/posener/complete"
)
Expand Down Expand Up @@ -586,7 +588,7 @@ func (c *DebugCommand) collectConsul(dir, consul string) error {
return nil
}

client := api.DefaultHttpClient()
client := defaultHttpClient()
api.ConfigureTLS(client, c.consul.tls)

req, _ := http.NewRequest("GET", addr+"/v1/agent/self", nil)
Expand All @@ -611,7 +613,7 @@ func (c *DebugCommand) collectVault(dir, vault string) error {
return nil
}

client := api.DefaultHttpClient()
client := defaultHttpClient()
api.ConfigureTLS(client, c.vault.tls)

req, _ := http.NewRequest("GET", addr+"/sys/health", nil)
Expand Down Expand Up @@ -865,3 +867,15 @@ func (e *external) token() string {

return ""
}

// defaultHttpClient configures a basic httpClient
func defaultHttpClient() *http.Client {
httpClient := cleanhttp.DefaultClient()
transport := httpClient.Transport.(*http.Transport)
transport.TLSHandshakeTimeout = 10 * time.Second
transport.TLSClientConfig = &tls.Config{
MinVersion: tls.VersionTLS12,
}

return httpClient
}

0 comments on commit a7cb497

Please sign in to comment.