diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-12-10 15:46:13 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-12-10 15:57:11 +0300 |
commit | 0a42fb86de9f0f4477ee2c4363b81d4754afb2b1 (patch) | |
tree | f18304a0e39eef572e80f4f4222e04e6abf36a4c /cmd/gitaly-hooks | |
parent | 451566532841a32f4386b4654a0504a86439b629 (diff) |
gitlabshell: Stop injecting configuration into environment
The `internal/gitlabshell` package was originally responsible to set up
the environment required by hooks. Since we stopped using gitlab-shell
for this and migrated to our Go infrastructure, injecting its
configuration isn't necessary anymore.
Currently, the package is responsible for injecting three environment
variables:
- The gitlab-shell configuration, which isn't read at all anymore by our
Go hooks. It encoded things like custom hooks directories, logging
settings as well as the GitLab URL. But these are nowadays stored in
the actual Go services and not used by the hook, which always defer to
the services.
- The GITALY_BIN_DIR is required, as it is used by our hooks script to
identify the location of the actual gitaly-hooks binary. It's thus
only required where we actually spawn those executables. We already
inject this variable in `internal/git/hooks.go`, so there is no need
to keep it around here. Thhe Ruby sidcar instead internally uses
GITALY_RUBY_GITALY_BIN_DIR to locate them, so we don't need it there
either.
- The GITALY_LOG_DIR is required, as it is used by gitaly-hooks to
optionally enable logging to a file in that directory. It's currently
only injected via `receivePackHookEnv`, but it should also be for all
the other hooks. This commit thus moves injection into `refHookEnv`.
With this, we now have all environment variables set up everywhere,
making the package absolete. So let's just remove it altogether and end
an era.
Diffstat (limited to 'cmd/gitaly-hooks')
-rw-r--r-- | cmd/gitaly-hooks/hooks_test.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index 47c73425a..c0efd9cfa 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -21,7 +21,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" gitalyhook "gitlab.com/gitlab-org/gitaly/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook" - "gitlab.com/gitlab-org/gitaly/internal/gitlabshell" gitalylog "gitlab.com/gitlab-org/gitaly/internal/log" "gitlab.com/gitlab-org/gitaly/internal/praefect/metadata" "gitlab.com/gitlab-org/gitaly/internal/testhelper" @@ -40,15 +39,12 @@ type proxyValues struct { // envForHooks generates a set of environment variables for gitaly hooks func envForHooks(t testing.TB, gitlabShellDir string, repo *gitalypb.Repository, glHookValues glHookValues, proxyValues proxyValues, gitPushOptions ...string) []string { - env, err := gitlabshell.EnvFromConfig(config.Config) - require.NoError(t, err) - payload, err := git.NewHooksPayload(config.Config, repo, nil, nil).Env() require.NoError(t, err) - env = append(env, os.Environ()...) - env = append(env, []string{ + env := append(os.Environ(), []string{ payload, + "GITALY_BIN_DIR=" + config.Config.BinDir, fmt.Sprintf("GL_ID=%s", glHookValues.GLID), fmt.Sprintf("GL_REPOSITORY=%s", glHookValues.GLRepo), fmt.Sprintf("GL_PROTOCOL=%s", glHookValues.GLProtocol), |