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:
authorSean Carroll <scarroll@gitlab.com>2019-10-18 15:39:48 +0300
committerSean Carroll <scarroll@gitlab.com>2019-10-18 15:39:48 +0300
commit64a49c238c56655d32211e5cc4436b5fcaa2d396 (patch)
treeec29e5c172d2b4350481209b67da42bc2c70a594 /main.go
parentfc8f04d5fef6d36568f751e0ebb724a22959cb96 (diff)
Secrets should not allowed on command line
Diffstat (limited to 'main.go')
-rw-r--r--main.go63
1 files changed, 35 insertions, 28 deletions
diff --git a/main.go b/main.go
index 8c3ded3d..9b56d1b4 100644
--- a/main.go
+++ b/main.go
@@ -12,6 +12,7 @@ import (
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/labkit/errortracking"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/deprecatedargs"
"gitlab.com/gitlab-org/gitlab-pages/internal/host"
"gitlab.com/gitlab-org/gitlab-pages/internal/logging"
"gitlab.com/gitlab-org/gitlab-pages/internal/tlsconfig"
@@ -203,30 +204,9 @@ func initErrorReporting(sentryDSN, sentryEnvironment string) {
errortracking.WithSentryEnvironment(sentryEnvironment))
}
-func appMain() {
- var showVersion = flag.Bool("version", false, "Show version")
-
- flag.String(flag.DefaultConfigFlagname, "", "path to config file")
- flag.Parse()
- if err := tlsconfig.ValidateTLSVersions(*tlsMinVersion, *tlsMaxVersion); err != nil {
- fatal(err)
- }
-
- printVersion(*showVersion, VERSION)
-
- err := logging.ConfigureLogging(*logFormat, *logVerbose)
- if err != nil {
- log.WithError(err).Fatal("Failed to initialize logging")
- }
-
- log.WithFields(log.Fields{
- "version": VERSION,
- "revision": REVISION,
- }).Print("GitLab Pages Daemon")
- log.Printf("URL: https://gitlab.com/gitlab-org/gitlab-pages")
-
- if err := os.Chdir(*pagesRoot); err != nil {
- fatal(err)
+func loadConfig() appConfig {
+ if err := deprecatedargs.Validate(os.Args[1:]); err != nil {
+ log.WithError(err)
}
config := configFromFlags()
@@ -264,14 +244,41 @@ func appMain() {
"tls-min-version": *tlsMinVersion,
"tls-max-version": *tlsMaxVersion,
"use-http-2": config.HTTP2,
- "auth-secret": config.StoreSecret,
"gitlab-server": config.GitLabServer,
- "auth-client-id": config.ClientID,
- "auth-client-secret": config.ClientSecret,
"auth-redirect-uri": config.RedirectURI,
- "sentry-dsn": config.SentryDSN,
}).Debug("Start daemon with configuration")
+ return config
+}
+
+func appMain() {
+ var showVersion = flag.Bool("version", false, "Show version")
+
+ flag.String(flag.DefaultConfigFlagname, "", "path to config file")
+ flag.Parse()
+ if err := tlsconfig.ValidateTLSVersions(*tlsMinVersion, *tlsMaxVersion); err != nil {
+ fatal(err)
+ }
+
+ printVersion(*showVersion, VERSION)
+
+ err := logging.ConfigureLogging(*logFormat, *logVerbose)
+ if err != nil {
+ log.WithError(err).Fatal("Failed to initialize logging")
+ }
+
+ log.WithFields(log.Fields{
+ "version": VERSION,
+ "revision": REVISION,
+ }).Print("GitLab Pages Daemon")
+ log.Printf("URL: https://gitlab.com/gitlab-org/gitlab-pages")
+
+ if err := os.Chdir(*pagesRoot); err != nil {
+ fatal(err)
+ }
+
+ config := loadConfig()
+
for _, cs := range [][]io.Closer{
createAppListeners(&config),
createMetricsListener(&config),