diff --git a/pkg/support/testSupport.go b/pkg/support/testSupport.go index e1de719..2ea693e 100644 --- a/pkg/support/testSupport.go +++ b/pkg/support/testSupport.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "path/filepath" "strings" @@ -82,8 +83,30 @@ func DownloadAndUntarArchive(ctx context.Context, link string, dst string) error return UntarArchive(dst, pr) } +const squidProxy = "http://squid.corp.redhat.com:3128" + +var stagingProxySuffixes = []string{ + ".qa.redhat.com", + ".dev.redhat.com", + ".stage.redhat.com", + ".preprod.redhat.com", +} + +func proxyForStagingOnly(req *http.Request) (*url.URL, error) { + host := req.URL.Hostname() + for _, suffix := range stagingProxySuffixes { + if strings.HasSuffix(host, suffix) { + return url.Parse(squidProxy) + } + } + return nil, nil +} + func Download(ctx context.Context, link string, writer io.Writer) (int64, error) { - client := &http.Client{Timeout: 2 * time.Minute} //nolint:mnd + client := &http.Client{ + Timeout: 2 * time.Minute, //nolint:mnd + Transport: &http.Transport{Proxy: proxyForStagingOnly}, + } const maxRetries = 5 var lastErr error