diff options
author | Stan Hu <stanhu@gmail.com> | 2020-11-08 08:19:20 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2020-11-08 09:54:03 +0300 |
commit | a9f808a5fa39a4458500ef96f86e65ad8453167a (patch) | |
tree | e7a8ef0bea2da19a5a2e12e8a36c2fd70ee03936 | |
parent | 51fac02aa9ef070ac493ca0e27c0d227838b3e70 (diff) |
Move GITALY_LOG_DIR into a constant
-rw-r--r-- | cmd/gitaly-lfs-smudge/lfs_smudge.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/repository/archive.go | 3 | ||||
-rw-r--r-- | internal/gitlabshell/env.go | 4 | ||||
-rw-r--r-- | internal/log/hook.go | 2 | ||||
-rw-r--r-- | internal/log/log.go | 2 | ||||
-rw-r--r-- | internal/testhelper/testserver.go | 3 |
6 files changed, 12 insertions, 5 deletions
diff --git a/cmd/gitaly-lfs-smudge/lfs_smudge.go b/cmd/gitaly-lfs-smudge/lfs_smudge.go index a36bf3877..d08716404 100644 --- a/cmd/gitaly-lfs-smudge/lfs_smudge.go +++ b/cmd/gitaly-lfs-smudge/lfs_smudge.go @@ -10,6 +10,7 @@ import ( "github.com/git-lfs/git-lfs/lfs" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/gitaly/hook" + gitalylog "gitlab.com/gitlab-org/gitaly/internal/log" "gitlab.com/gitlab-org/labkit/log" "gitlab.com/gitlab-org/labkit/tracing" ) @@ -19,7 +20,7 @@ type configProvider interface { } func initLogging(p configProvider) (io.Closer, error) { - path := p.Get("GITALY_LOG_DIR") + path := p.Get(gitalylog.GitalyLogDirEnvKey) if path == "" { return nil, nil } diff --git a/internal/gitaly/service/repository/archive.go b/internal/gitaly/service/repository/archive.go index 6428d33a9..61abdee28 100644 --- a/internal/gitaly/service/repository/archive.go +++ b/internal/gitaly/service/repository/archive.go @@ -15,6 +15,7 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/commit" "gitlab.com/gitlab-org/gitaly/internal/helper" + "gitlab.com/gitlab-org/gitaly/internal/log" "gitlab.com/gitlab-org/gitaly/internal/storage" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/streamio" @@ -188,7 +189,7 @@ func handleArchive(p archiveParams) error { fmt.Sprintf("GL_PROJECT_PATH=%s", p.in.GetRepository().GetGlProjectPath()), fmt.Sprintf("GL_INTERNAL_CONFIG=%s", p.internalCfg), fmt.Sprintf("CORRELATION_ID=%s", correlation.ExtractFromContext(p.ctx)), - fmt.Sprintf("GITALY_LOG_DIR=%s", p.loggingDir), + fmt.Sprintf("%s=%s", log.GitalyLogDirEnvKey, p.loggingDir), } var globals []git.Option diff --git a/internal/gitlabshell/env.go b/internal/gitlabshell/env.go index 763001318..6a859c967 100644 --- a/internal/gitlabshell/env.go +++ b/internal/gitlabshell/env.go @@ -2,8 +2,10 @@ package gitlabshell import ( "encoding/json" + "fmt" "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" + "gitlab.com/gitlab-org/gitaly/internal/log" ) // Env is a helper that returns a slice with environment variables used by gitlab shell @@ -45,7 +47,7 @@ func EnvFromConfig(cfg config.Cfg) ([]string, error) { return []string{ //TODO: remove GITALY_GITLAB_SHELL_DIR: https://gitlab.com/gitlab-org/gitaly/-/issues/2679 "GITALY_GITLAB_SHELL_DIR=" + cfg.GitlabShell.Dir, - "GITALY_LOG_DIR=" + cfg.Logging.Dir, + fmt.Sprintf("%s=%s", log.GitalyLogDirEnvKey, cfg.Logging.Dir), "GITALY_LOG_FORMAT=" + cfg.Logging.Format, "GITALY_LOG_LEVEL=" + cfg.Logging.Level, "GITALY_BIN_DIR=" + cfg.BinDir, diff --git a/internal/log/hook.go b/internal/log/hook.go index a8219b376..e0fe7959b 100644 --- a/internal/log/hook.go +++ b/internal/log/hook.go @@ -18,7 +18,7 @@ type HookLogger struct { func NewHookLogger() *HookLogger { logger := logrus.New() - filepath := filepath.Join(os.Getenv("GITALY_LOG_DIR"), "gitaly_hooks.log") + filepath := filepath.Join(os.Getenv(GitalyLogDirEnvKey), "gitaly_hooks.log") logFile, err := os.OpenFile(filepath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) if err != nil { diff --git a/internal/log/log.go b/internal/log/log.go index cd2271413..1e3a251f5 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -6,6 +6,8 @@ import ( "github.com/sirupsen/logrus" ) +const GitalyLogDirEnvKey = "GITALY_LOG_DIR" + var ( defaultLogger = logrus.StandardLogger() grpcGo = logrus.New() diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go index c542d9d28..b8d1d94f4 100644 --- a/internal/testhelper/testserver.go +++ b/internal/testhelper/testserver.go @@ -33,6 +33,7 @@ import ( serverauth "gitlab.com/gitlab-org/gitaly/internal/gitaly/server/auth" "gitlab.com/gitlab-org/gitaly/internal/gitlabshell" "gitlab.com/gitlab-org/gitaly/internal/helper/fieldextractors" + gitalylog "gitlab.com/gitlab-org/gitaly/internal/log" praefectconfig "gitlab.com/gitlab-org/gitaly/internal/praefect/config" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" grpccorrelation "gitlab.com/gitlab-org/labkit/correlation/grpc" @@ -924,7 +925,7 @@ func EnvForHooks(t testing.TB, gitlabShellDir, gitalySocket, gitalyToken string, fmt.Sprintf("GITALY_TOKEN=%s", gitalyToken), fmt.Sprintf("GITALY_REPO=%v", repoString), fmt.Sprintf("GITALY_GITLAB_SHELL_DIR=%s", gitlabShellDir), - fmt.Sprintf("GITALY_LOG_DIR=%s", gitlabShellDir), + fmt.Sprintf("%s=%s", gitalylog.GitalyLogDirEnvKey, gitlabShellDir), }...) env = append(env, hooks.GitPushOptions(gitPushOptions)...) |