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:
authorVladimir Shushlin <vshushlin@gitlab.com>2021-08-10 10:51:28 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2021-08-10 10:51:28 +0300
commitca49f3b9de0e9f8f186b9c47147eea883b68e7ac (patch)
treefd9f7d08e2d1744d67fec3a3cd10852387b00b72
parentfb8ad8e35513b6b2ca230f9f814ae06ec19ae806 (diff)
parent5186f78c179578757a2673264155aa8b287a0efb (diff)
Merge branch 'do-not-fail-for-version' into 'master'
fix: do not fail to print --version See merge request gitlab-org/gitlab-pages!539
-rw-r--r--app_test.go7
-rw-r--r--internal/config/config.go4
-rw-r--r--internal/config/validate.go3
-rw-r--r--main.go4
4 files changed, 6 insertions, 12 deletions
diff --git a/app_test.go b/app_test.go
index 669d041e..48a6013b 100644
--- a/app_test.go
+++ b/app_test.go
@@ -6,7 +6,6 @@ import (
"io"
"net/http"
"net/http/httptest"
- "os"
"testing"
"github.com/stretchr/testify/require"
@@ -85,12 +84,6 @@ func TestHealthCheckMiddleware(t *testing.T) {
},
}
- // required by LoadConfig
- require.NoError(t, os.Setenv("LISTEN_HTTP", ":0"))
- t.Cleanup(func() {
- require.NoError(t, os.Unsetenv("LISTEN_HTTP"))
- })
-
cfg, err := config.LoadConfig()
require.NoError(t, err)
cfg.General.StatusPath = "/-/healthcheck"
diff --git a/internal/config/config.go b/internal/config/config.go
index 9261b705..64dc4666 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -291,10 +291,6 @@ func loadConfig() (*Config, error) {
config.Zip.ChrootPath = *pagesRoot
}
- if err := validateConfig(config); err != nil {
- return nil, err
- }
-
return config, nil
}
diff --git a/internal/config/validate.go b/internal/config/validate.go
index 87f932c0..3831b45b 100644
--- a/internal/config/validate.go
+++ b/internal/config/validate.go
@@ -9,7 +9,8 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/config/tls"
)
-func validateConfig(config *Config) error {
+// Validate values populated in Config
+func Validate(config *Config) error {
if err := validateListeners(config); err != nil {
return err
}
diff --git a/main.go b/main.go
index 09066e2c..042e5974 100644
--- a/main.go
+++ b/main.go
@@ -50,6 +50,10 @@ func appMain() {
printVersion(config.General.ShowVersion, VERSION)
+ if err := cfg.Validate(config); err != nil {
+ log.WithError(err).Fatal("invalid config settings")
+ }
+
if config.Sentry.DSN != "" {
initErrorReporting(config.Sentry.DSN, config.Sentry.Environment)
}