diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-02-23 17:44:26 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-03-01 10:31:10 +0300 |
commit | b30cee8caa34d4faaa7d9e3fe4c7daa692c88698 (patch) | |
tree | 7904a8dce1f46f2eca23690bb53290c02cea8073 | |
parent | dfbb45a122472e12da90f49e719bfab4ccb26c58 (diff) |
git: Reject config with bundled Git and missing binary directories
When bundled Git is configured then the binaries are expected to be
contained in Gitaly's binary directory. It is thus mandatory for the
directory to be set, or else the resulting execution environment cannot
actually be a valid one. And while we already reject the case where the
binary directory is unset in case the `GITALY_TESTING_BUNDLED_GIT_PATH`
environment variable is set, we don't have such a test for "normal"
setups.
Add the missing sanify check.
Changelog: fixed
-rw-r--r-- | internal/git/execution_environment.go | 4 | ||||
-rw-r--r-- | internal/git/execution_environment_test.go | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/git/execution_environment.go b/internal/git/execution_environment.go index a85ea9952..633b16cbe 100644 --- a/internal/git/execution_environment.go +++ b/internal/git/execution_environment.go @@ -162,6 +162,10 @@ func (c BundledGitEnvironmentConstructor) Construct(cfg config.Cfg) (_ Execution return ExecutionEnvironment{}, ErrNotConfigured } + if cfg.BinDir == "" { + return ExecutionEnvironment{}, errors.New("cannot use bundled binaries without bin path being set") + } + // In order to support having a single Git binary only as compared to a complete Git // installation, we create our own GIT_EXEC_PATH which contains symlinks to the Git // binary for executables which Git expects to be present. diff --git a/internal/git/execution_environment_test.go b/internal/git/execution_environment_test.go index 34025952d..31b9221b4 100644 --- a/internal/git/execution_environment_test.go +++ b/internal/git/execution_environment_test.go @@ -82,16 +82,12 @@ func TestBundledGitEnvironmentConstructor(t *testing.T) { }) t.Run("bundled Git without binary directory fails", func(t *testing.T) { - execEnv, err := constructor.Construct(config.Cfg{ + _, err := constructor.Construct(config.Cfg{ Git: config.Git{ UseBundledBinaries: true, }, }) - - // It is a bug that this succeeds: if the binary directory is not set we cannot - // derive the location of the bundled Git executables either. - require.NoError(t, err) - defer execEnv.Cleanup() + require.Equal(t, errors.New("cannot use bundled binaries without bin path being set"), err) }) t.Run("incomplete binary directory succeeds", func(t *testing.T) { |