From 0584c20b0c14a89e833b875252114ceff61805e8 Mon Sep 17 00:00:00 2001 From: Lukas Zapletal Date: Thu, 14 Nov 2024 19:37:30 +0100 Subject: [PATCH] worker: parse ostree proxy early --- pkg/ostree/ostree.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/ostree/ostree.go b/pkg/ostree/ostree.go index a665d90ac7..02f762056c 100644 --- a/pkg/ostree/ostree.go +++ b/pkg/ostree/ostree.go @@ -161,10 +161,6 @@ func resolveRef(ss SourceSpec) (string, error) { u.Path = path.Join(u.Path, "refs/heads/", ss.Ref) transport := http.DefaultTransport.(*http.Transport).Clone() - client := &http.Client{ - Transport: transport, - Timeout: 300 * time.Second, - } if u.Scheme == "https" { tlsConf := &tls.Config{ MinVersion: tls.VersionTLS12, @@ -194,11 +190,21 @@ func resolveRef(ss SourceSpec) (string, error) { } if ss.Proxy != "" { + proxyURL, err := url.Parse(ss.URL) + if err != nil { + return "", NewResolveRefError("error parsing MTLS proxy URL '%s': %v", ss.URL, err) + } + transport.Proxy = func(request *http.Request) (*url.URL, error) { - return url.Parse(ss.Proxy) + return proxyURL, nil } } + client := &http.Client{ + Transport: transport, + Timeout: 300 * time.Second, + } + req, err := http.NewRequest(http.MethodGet, u.String(), nil) if err != nil { return "", NewResolveRefError("error preparing ostree resolve request: %s", err)