Skip to content
Merged
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
25 changes: 24 additions & 1 deletion pkg/support/testSupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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
Expand Down
Loading