Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of http.DefaultClient #3532

Merged
merged 3 commits into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"net/http"
"strings"

"github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -98,6 +99,7 @@ func (c *Config) Client() (interface{}, error) {
Credentials: creds,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
HTTPClient: &http.Client{},
}

log.Println("[INFO] Initializing IAM Connection")
Expand All @@ -123,6 +125,7 @@ func (c *Config) Client() (interface{}, error) {
Credentials: creds,
Region: aws.String("us-east-1"),
MaxRetries: aws.Int(c.MaxRetries),
HTTPClient: &http.Client{},
}

log.Println("[INFO] Initializing DynamoDB connection")
Expand Down
6 changes: 5 additions & 1 deletion builtin/providers/dme/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package dme

import (
"fmt"
"github.com/soniah/dnsmadeeasy"
"log"
"net/http"

"github.com/soniah/dnsmadeeasy"
)

// Config contains DNSMadeEasy provider settings
Expand All @@ -20,6 +22,8 @@ func (c *Config) Client() (*dnsmadeeasy.Client, error) {
return nil, fmt.Errorf("Error setting up client: %s", err)
}

client.HTTP = &http.Client{}

if c.UseSandbox {
client.URL = dnsmadeeasy.SandboxURL
}
Expand Down
4 changes: 3 additions & 1 deletion builtin/providers/packet/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package packet

import (
"net/http"

"github.com/packethost/packngo"
)

Expand All @@ -14,5 +16,5 @@ type Config struct {

// Client() returns a new client for accessing packet.
func (c *Config) Client() *packngo.Client {
return packngo.NewClient(consumerToken, c.AuthToken)
return packngo.NewClient(consumerToken, c.AuthToken, &http.Client{})
}
9 changes: 6 additions & 3 deletions state/remote/atlas.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func (c *AtlasClient) Get() (*Payload, error) {
}

// Request the url
resp, err := http.DefaultClient.Do(req)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -161,7 +162,8 @@ func (c *AtlasClient) Put(state []byte) error {
req.ContentLength = int64(len(state))

// Make the request
resp, err := http.DefaultClient.Do(req)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("Failed to upload state: %v", err)
}
Expand All @@ -186,7 +188,8 @@ func (c *AtlasClient) Delete() error {
}

// Make the request
resp, err := http.DefaultClient.Do(req)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("Failed to delete state: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion state/remote/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestHTTPClient(t *testing.T) {
t.Fatalf("err: %s", err)
}

client := &HTTPClient{URL: url, Client: http.DefaultClient}
client := &HTTPClient{URL: url, Client: &http.Client{}}
testClient(t, client)
}

Expand Down
2 changes: 2 additions & 0 deletions state/remote/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log"
"net/http"
"os"
"strconv"

Expand Down Expand Up @@ -75,6 +76,7 @@ func s3Factory(conf map[string]string) (Client, error) {
awsConfig := &aws.Config{
Credentials: credentialsProvider,
Region: aws.String(regionName),
HTTPClient: &http.Client{},
}
nativeClient := s3.New(awsConfig)

Expand Down