Skip to content

Commit

Permalink
Revert "enable proxy for remaining clients (#152)"
Browse files Browse the repository at this point in the history
This reverts commit 293835e.

It's unnecessary to specify ProxyFromEnvironment in these cases.
It was required for the selfhosted client, as we are overriding the
default Transport object.

In these cases, Transport are nil, and so should default to
DefaultTransport: https://cs.opensource.google/go/go/+/refs/tags/go1.22.0:src/net/http/client.go;l=60

This already has ProxyFromEnvironment as the default behaviour:
https://github.com/golang/go/blob/master/src/net/http/transport.go#L44

As this is unnecessary, it's better to leave it undefined to ensure that
the other characteristics of DefaultTransport are retained.
  • Loading branch information
aidy committed Mar 8, 2024
1 parent 8473f86 commit e47f53d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions pkg/client/acr/acr.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ type ACRManifestResponse struct {

func New(opts Options) (*Client, error) {
client := &http.Client{
Timeout: time.Second * 5,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
Timeout: time.Second * 5,
}

if len(opts.RefreshToken) > 0 &&
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ type Image struct {

func New(ctx context.Context, opts Options) (*Client, error) {
client := &http.Client{
Timeout: time.Second * 10,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
Timeout: time.Second * 10,
}

// Setup Auth if username and password used.
Expand Down
3 changes: 0 additions & 3 deletions pkg/client/ecr/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ecr
import (
"context"
"fmt"
"net/http"
"sync"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -103,8 +102,6 @@ func (c *Client) getClient(region string) (*ecr.ECR, error) {
return nil, err
}
}
// Try and use an HTTP(S) Proxies defined within Environment variables.
client.Config.WithHTTPClient(&http.Client{Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}})

c.cachedRegionClients[region] = client
return client, nil
Expand Down
9 changes: 3 additions & 6 deletions pkg/client/gcr/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ type ManifestItem struct {
}

func New(opts Options) *Client {
client := &http.Client{
Timeout: time.Second * 5,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
}

return &Client{
Options: opts,
Client: client,
Client: &http.Client{
Timeout: time.Second * 5,
},
}
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/client/ghcr/ghcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func New(opts Options) *Client {
return &Client{
Options: opts,
Client: &http.Client{
Timeout: time.Second * 5,
Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
Timeout: time.Second * 5,
},
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/client/quay/quay.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type responseManifestDataItem struct {

func New(opts Options) *Client {
client := retryablehttp.NewClient()
client.HTTPClient.Transport = &http.Transport{Proxy: http.ProxyFromEnvironment}
client.RetryMax = 10
client.Logger = nil

Expand Down

0 comments on commit e47f53d

Please sign in to comment.