Skip to content

Commit

Permalink
enable proxy for remaining clients (jetstack#152)
Browse files Browse the repository at this point in the history
Co-authored-by: Arvid Bjurklint <arvid.bjurklint@sr.se>
Co-authored-by: Joshua Wright <19779568+joshw123@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent 9dbe07e commit 293835e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/client/acr/acr.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type ACRManifestResponse struct {

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

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

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

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

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -102,6 +103,8 @@ 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: 6 additions & 3 deletions pkg/client/gcr/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ 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: &http.Client{
Timeout: time.Second * 5,
},
Client: client,
}
}

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

Please sign in to comment.