diff options
author | John Cai <jcai@gitlab.com> | 2020-06-02 03:25:10 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2020-06-02 03:25:10 +0300 |
commit | a85e948c8f6031d85e2aade33c942ce15fea00d3 (patch) | |
tree | ec5622a315c1e2ab99ac253bb17f918da1ce77a2 /internal/testhelper | |
parent | 414c9b7c075bae42bd929be7e5abfee52770bfe6 (diff) |
Revert "Merge branch 'jc-deprecate-gitlab-shell-yml' into 'master'"
This reverts commit 414c9b7c075bae42bd929be7e5abfee52770bfe6, reversing
changes made to 3b0d832d1d7162528d35171516969509beee7ead.
Diffstat (limited to 'internal/testhelper')
-rw-r--r-- | internal/testhelper/testserver.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go index a73f4d64b..26f990aa7 100644 --- a/internal/testhelper/testserver.go +++ b/internal/testhelper/testserver.go @@ -38,6 +38,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/health" healthpb "google.golang.org/grpc/health/grpc_health_v1" + "gopkg.in/yaml.v2" ) // PraefectEnabled returns whether or not tests should use a praefect proxy @@ -683,6 +684,24 @@ func CreateTemporaryGitlabShellDir(t testing.TB) (string, func()) { } } +// WriteTemporaryGitlabShellConfigFile writes a gitlab shell config.yml in a temporary directory. It returns the path +// and a cleanup function +func WriteTemporaryGitlabShellConfigFile(t FatalLogger, dir string, config GitlabShellConfig) (string, func()) { + out, err := yaml.Marshal(&config) + if err != nil { + t.Fatalf("error marshalling config", err) + } + + path := filepath.Join(dir, "config.yml") + if err = ioutil.WriteFile(path, out, 0644); err != nil { + t.Fatalf("error writing gitlab shell config", err) + } + + return path, func() { + os.RemoveAll(path) + } +} + // WriteTemporaryGitalyConfigFile writes a gitaly toml file into a temporary directory. It returns the path to // the file as well as a cleanup function func WriteTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, password string) (string, func()) { @@ -690,11 +709,10 @@ func WriteTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, pass contents := fmt.Sprintf(` [gitlab-shell] dir = "%s/gitlab-shell" -[gitlab] -url = %q -[gitlab.http-settings] - user = %q - password = %q + gitlab_url = %q + [gitlab-shell.http-settings] + user = %q + password = %q `, tempDir, gitlabURL, user, password) require.NoError(t, ioutil.WriteFile(path, []byte(contents), 0644)) @@ -791,6 +809,7 @@ func NewHealthServerWithListener(t testing.TB, listener net.Listener) (*grpc.Ser func SetupAndStartGitlabServer(t FatalLogger, c *GitlabTestServerOptions) (string, func()) { ts := NewGitlabTestServer(*c) + WriteTemporaryGitlabShellConfigFile(t, config.Config.GitlabShell.Dir, GitlabShellConfig{GitlabURL: ts.URL}) WriteShellSecretFile(t, config.Config.GitlabShell.Dir, c.SecretToken) return ts.URL, func() { |