Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-08-18 09:56:12 +0300
committerTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-08-18 09:56:12 +0300
commit82335177a418afc9aeaab9cf117c94f5063fb1b7 (patch)
treee52a11b2cbad74cfc51459dfc6d862b9bd25beb8 /internal/artifact
parent1966ab9bf8592a32a7ff88e1d1439ed80f7f65bb (diff)
Combine transports to one package
Diffstat (limited to 'internal/artifact')
-rw-r--r--internal/artifact/artifact.go3
-rw-r--r--internal/artifact/transport.go55
2 files changed, 2 insertions, 56 deletions
diff --git a/internal/artifact/artifact.go b/internal/artifact/artifact.go
index 9a23e269..5050b426 100644
--- a/internal/artifact/artifact.go
+++ b/internal/artifact/artifact.go
@@ -12,6 +12,7 @@ import (
"time"
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/httptransport"
)
const (
@@ -43,7 +44,7 @@ func New(server string, timeoutSeconds int, pagesDomain string) *Artifact {
suffix: "." + strings.ToLower(pagesDomain),
client: &http.Client{
Timeout: time.Second * time.Duration(timeoutSeconds),
- Transport: transport,
+ Transport: httptransport.Transport,
},
}
}
diff --git a/internal/artifact/transport.go b/internal/artifact/transport.go
deleted file mode 100644
index da182df6..00000000
--- a/internal/artifact/transport.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package artifact
-
-import (
- "crypto/tls"
- "crypto/x509"
- "io/ioutil"
- "net"
- "net/http"
- "os"
- "sync"
-
- log "github.com/sirupsen/logrus"
-)
-
-var (
- sysPoolOnce = &sync.Once{}
- sysPool *x509.CertPool
-
- transport = &http.Transport{
- DialTLS: func(network, addr string) (net.Conn, error) {
- return tls.Dial(network, addr, &tls.Config{RootCAs: pool()})
- },
- }
-)
-
-// This is here because macOS does not support the SSL_CERT_FILE
-// environment variable. We have arrange things to read SSL_CERT_FILE as
-// late as possible to avoid conflicts with file descriptor passing at
-// startup.
-func pool() *x509.CertPool {
- sysPoolOnce.Do(loadPool)
- return sysPool
-}
-
-func loadPool() {
- sslCertFile := os.Getenv("SSL_CERT_FILE")
- if sslCertFile == "" {
- return
- }
-
- var err error
- sysPool, err = x509.SystemCertPool()
- if err != nil {
- log.WithError(err).Error("failed to load system cert pool for artifacts client")
- return
- }
-
- certPem, err := ioutil.ReadFile(sslCertFile)
- if err != nil {
- log.WithError(err).Error("failed to read SSL_CERT_FILE")
- return
- }
-
- sysPool.AppendCertsFromPEM(certPem)
-}