diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-11-19 03:53:30 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-11-30 02:15:10 +0300 |
commit | d28903a32e2bfa8a80547e639e941eac4843034f (patch) | |
tree | b66ecbcf804287740fd8d3771b88e94c6ed42185 /internal | |
parent | 22ede0d8ea69bf26929825a75dad4172ef25cc26 (diff) |
Log zip config
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/config.go | 6 | ||||
-rw-r--r-- | internal/serving/disk/zip/serving_test.go | 5 | ||||
-rw-r--r-- | internal/vfs/zip/archive_test.go | 7 | ||||
-rw-r--r-- | internal/vfs/zip/vfs.go | 2 |
4 files changed, 18 insertions, 2 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index b5fd834b..527b423b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "time" "github.com/namsral/flag" @@ -10,7 +11,7 @@ import ( var Default *Config // TODO: move all flags to this package, including flag.Parse() -func init() { +func Init() { Default = &Config{ Zip: &ZipServing{}, } @@ -19,6 +20,9 @@ func init() { flag.DurationVar(&Default.Zip.CleanupInterval, "zip-cache-cleanup", 30*time.Second, "Zip serving archive cache cleanup interval") flag.DurationVar(&Default.Zip.RefreshInterval, "zip-cache-refresh", 30*time.Second, "Zip serving archive cache refresh interval") flag.DurationVar(&Default.Zip.OpenTimeout, "zip-open-timeout", 30*time.Second, "Zip archive open timeout") + + // flag.Parse() + fmt.Printf("init: CONFIG: %+v\n", Default.Zip) } type Config struct { diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go index bca2ae51..9a7618fe 100644 --- a/internal/serving/disk/zip/serving_test.go +++ b/internal/serving/disk/zip/serving_test.go @@ -8,10 +8,15 @@ import ( "github.com/stretchr/testify/require" + cfg "gitlab.com/gitlab-org/gitlab-pages/internal/config" "gitlab.com/gitlab-org/gitlab-pages/internal/serving" "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers" ) +func init() { + cfg.Init() +} + func TestZip_ServeFileHTTP(t *testing.T) { testServerURL, cleanup := newZipFileServerURL(t, "group/zip.gitlab.io/public-without-dirs.zip") defer cleanup() diff --git a/internal/vfs/zip/archive_test.go b/internal/vfs/zip/archive_test.go index 3273edad..37e81d7a 100644 --- a/internal/vfs/zip/archive_test.go +++ b/internal/vfs/zip/archive_test.go @@ -19,9 +19,14 @@ import ( var ( chdirSet = false - zipCfg = config.Default.Zip + zipCfg *config.ZipServing ) +func init() { + config.Init() + zipCfg = config.Default.Zip +} + func TestOpen(t *testing.T) { zip, cleanup := openZipArchive(t, nil) defer cleanup() diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go index d90d4796..f853b0b9 100644 --- a/internal/vfs/zip/vfs.go +++ b/internal/vfs/zip/vfs.go @@ -3,6 +3,7 @@ package zip import ( "context" "errors" + "fmt" "net/url" "sync" "time" @@ -49,6 +50,7 @@ type zipVFS struct { // New creates a zipVFS instance that can be used by a serving request func New(cfg *config.ZipServing) vfs.VFS { + fmt.Printf("\n\n\n what the config?: %+v\n\n\n", cfg) zipVFS := &zipVFS{ cacheExpirationInterval: cfg.ExpirationInterval, cacheRefreshInterval: cfg.RefreshInterval, |