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:
authorJaime Martinez <jmartinez@gitlab.com>2020-11-30 13:57:22 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-11-30 14:02:12 +0300
commit14e61effff77b6dde9effc665a13c82bec509067 (patch)
treebc68bb36be3003ef494545b3282ac9fa01951136
parent9c51d46d39c1a2614aafca02bf1f3376a88e0280 (diff)
Call reconfigure explicitly
-rw-r--r--app.go5
-rw-r--r--internal/serving/disk/zip/serving.go15
-rw-r--r--internal/serving/disk/zip/serving_test.go2
3 files changed, 8 insertions, 14 deletions
diff --git a/app.go b/app.go
index 5468036d..ccd107fb 100644
--- a/app.go
+++ b/app.go
@@ -29,6 +29,7 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/middleware"
"gitlab.com/gitlab-org/gitlab-pages/internal/netutil"
"gitlab.com/gitlab-org/gitlab-pages/internal/request"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/zip"
"gitlab.com/gitlab-org/gitlab-pages/internal/source"
"gitlab.com/gitlab-org/gitlab-pages/internal/tlsconfig"
"gitlab.com/gitlab-org/gitlab-pages/metrics"
@@ -510,6 +511,10 @@ func runApp(config appConfig) {
cfg.Default.Zip.RefreshInterval = config.ZipCacheRefresh
cfg.Default.Zip.OpenTimeout = config.ZipeOpenTimeout
+ if err := zip.Instance().Reconfigure(cfg.Default); err != nil {
+ fatal(err, "failed to reconfigure zip VFS")
+ }
+
a.Run()
}
diff --git a/internal/serving/disk/zip/serving.go b/internal/serving/disk/zip/serving.go
index b31d9090..6d21f771 100644
--- a/internal/serving/disk/zip/serving.go
+++ b/internal/serving/disk/zip/serving.go
@@ -1,10 +1,6 @@
package zip
import (
- "sync"
-
- "gitlab.com/gitlab-org/labkit/log"
-
"gitlab.com/gitlab-org/gitlab-pages/internal/config"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk"
@@ -12,19 +8,10 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs/zip"
)
-var (
- once sync.Once
- instance = disk.New(vfs.Instrumented(zip.New(config.Default.Zip)))
-)
+var instance = disk.New(vfs.Instrumented(zip.New(config.Default.Zip)))
// Instance returns a serving instance that is capable of reading files
// from a zip archives opened from a URL, most likely stored in object storage
func Instance() serving.Serving {
- once.Do(func() {
- if err := instance.Reconfigure(config.Default); err != nil {
- log.WithError(err).Fatal("failed to reconfigure zip serving")
- }
- })
-
return instance
}
diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go
index 5bf16d7b..40b8e02a 100644
--- a/internal/serving/disk/zip/serving_test.go
+++ b/internal/serving/disk/zip/serving_test.go
@@ -62,6 +62,8 @@ func TestZip_ServeFileHTTP(t *testing.T) {
OpenTimeout: 5 * time.Second,
}
s := Instance()
+ err := s.Reconfigure(config.Default)
+ require.NoError(t, err)
for name, test := range tests {
t.Run(name, func(t *testing.T) {