Merge pull request #3532 from hashicorp/remove-default-client
Remove usage of http.DefaultClient
This commit is contained in:
commit
15a36d06cf
|
@ -3,6 +3,7 @@ package aws
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
|
@ -98,6 +99,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
Region: aws.String(c.Region),
|
Region: aws.String(c.Region),
|
||||||
MaxRetries: aws.Int(c.MaxRetries),
|
MaxRetries: aws.Int(c.MaxRetries),
|
||||||
|
HTTPClient: &http.Client{},
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[INFO] Initializing IAM Connection")
|
log.Println("[INFO] Initializing IAM Connection")
|
||||||
|
@ -123,6 +125,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
Region: aws.String("us-east-1"),
|
Region: aws.String("us-east-1"),
|
||||||
MaxRetries: aws.Int(c.MaxRetries),
|
MaxRetries: aws.Int(c.MaxRetries),
|
||||||
|
HTTPClient: &http.Client{},
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[INFO] Initializing DynamoDB connection")
|
log.Println("[INFO] Initializing DynamoDB connection")
|
||||||
|
|
|
@ -2,8 +2,10 @@ package dme
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/soniah/dnsmadeeasy"
|
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/soniah/dnsmadeeasy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains DNSMadeEasy provider settings
|
// Config contains DNSMadeEasy provider settings
|
||||||
|
@ -20,6 +22,8 @@ func (c *Config) Client() (*dnsmadeeasy.Client, error) {
|
||||||
return nil, fmt.Errorf("Error setting up client: %s", err)
|
return nil, fmt.Errorf("Error setting up client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.HTTP = &http.Client{}
|
||||||
|
|
||||||
if c.UseSandbox {
|
if c.UseSandbox {
|
||||||
client.URL = dnsmadeeasy.SandboxURL
|
client.URL = dnsmadeeasy.SandboxURL
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package packet
|
package packet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/packethost/packngo"
|
"github.com/packethost/packngo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,5 +16,5 @@ type Config struct {
|
||||||
|
|
||||||
// Client() returns a new client for accessing packet.
|
// Client() returns a new client for accessing packet.
|
||||||
func (c *Config) Client() *packngo.Client {
|
func (c *Config) Client() *packngo.Client {
|
||||||
return packngo.NewClient(consumerToken, c.AuthToken)
|
return packngo.NewClient(consumerToken, c.AuthToken, &http.Client{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,8 @@ func (c *AtlasClient) Get() (*Payload, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request the url
|
// Request the url
|
||||||
resp, err := http.DefaultClient.Do(req)
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -161,7 +162,8 @@ func (c *AtlasClient) Put(state []byte) error {
|
||||||
req.ContentLength = int64(len(state))
|
req.ContentLength = int64(len(state))
|
||||||
|
|
||||||
// Make the request
|
// Make the request
|
||||||
resp, err := http.DefaultClient.Do(req)
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to upload state: %v", err)
|
return fmt.Errorf("Failed to upload state: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -186,7 +188,8 @@ func (c *AtlasClient) Delete() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the request
|
// Make the request
|
||||||
resp, err := http.DefaultClient.Do(req)
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to delete state: %v", err)
|
return fmt.Errorf("Failed to delete state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestHTTPClient(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &HTTPClient{URL: url, Client: http.DefaultClient}
|
client := &HTTPClient{URL: url, Client: &http.Client{}}
|
||||||
testClient(t, client)
|
testClient(t, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ func s3Factory(conf map[string]string) (Client, error) {
|
||||||
awsConfig := &aws.Config{
|
awsConfig := &aws.Config{
|
||||||
Credentials: credentialsProvider,
|
Credentials: credentialsProvider,
|
||||||
Region: aws.String(regionName),
|
Region: aws.String(regionName),
|
||||||
|
HTTPClient: &http.Client{},
|
||||||
}
|
}
|
||||||
nativeClient := s3.New(awsConfig)
|
nativeClient := s3.New(awsConfig)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue