Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-27 11:55:42 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-27 12:13:12 +0300
commit74b9bce19aff24dcbf665ac846ef25ea9f594346 (patch)
treed846c6af3461d6ed3fa2b97b87b14a311d2f9241 /cmd/gitaly-hooks
parent286a951ade1dd86ae42acd731f18b0cdef506ba0 (diff)
gitlab: Move client for GitLab's internal API into separate package
The client for GitLab's internal API is currently part of the hooks package. While a subset of exposed functions are indeed related to hooks, others aren't. It's thus not really the right place to live. Split out teh client into its own package `internal/gitlab` to improve this.
Diffstat (limited to 'cmd/gitaly-hooks')
-rw-r--r--cmd/gitaly-hooks/hooks.go5
-rw-r--r--cmd/gitaly-hooks/hooks_test.go11
2 files changed, 9 insertions, 7 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index ffd61ead9..4f4814b69 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -16,6 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
+ "gitlab.com/gitlab-org/gitaly/internal/gitlab"
gitalylog "gitlab.com/gitlab-org/gitaly/internal/log"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/stream"
@@ -169,7 +170,7 @@ func sendFunc(reqWriter io.Writer, stream grpc.ClientStream, stdin io.Reader) fu
}
}
-func check(configPath string) (*hook.CheckInfo, error) {
+func check(configPath string) (*gitlab.CheckInfo, error) {
cfgFile, err := os.Open(configPath)
if err != nil {
return nil, fmt.Errorf("failed to open config file: %w", err)
@@ -181,7 +182,7 @@ func check(configPath string) (*hook.CheckInfo, error) {
return nil, err
}
- gitlabAPI, err := hook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
+ gitlabAPI, err := gitlab.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
if err != nil {
return nil, err
}
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index a79baf910..00aa8d897 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -26,6 +26,7 @@ import (
gitalyhook "gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
+ "gitlab.com/gitlab-org/gitaly/internal/gitlab"
gitalylog "gitlab.com/gitlab-org/gitaly/internal/log"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/praefect/metadata"
@@ -171,7 +172,7 @@ func testHooksPrePostReceive(t *testing.T, cfg config.Cfg, repo *gitalypb.Reposi
t.Run(fmt.Sprintf("hookName: %s", hookName), func(t *testing.T) {
customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, hookName)
- gitlabAPI, err := gitalyhook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
+ gitlabAPI, err := gitlab.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
require.NoError(t, err)
stop := runHookServiceServerWithAPI(t, cfg, gitlabAPI)
@@ -350,7 +351,7 @@ func TestHooksPostReceiveFailed(t *testing.T) {
cfg.Gitlab.URL = serverURL
cfg.Gitlab.SecretFile = testhelper.WriteShellSecretFile(t, cfg.GitlabShell.Dir, secretToken)
- gitlabAPI, err := gitalyhook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
+ gitlabAPI, err := gitlab.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
require.NoError(t, err)
customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
@@ -464,7 +465,7 @@ func TestHooksNotAllowed(t *testing.T) {
customHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "post-receive")
- gitlabAPI, err := gitalyhook.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
+ gitlabAPI, err := gitlab.NewGitlabAPI(cfg.Gitlab, cfg.TLS)
require.NoError(t, err)
stop := runHookServiceServerWithAPI(t, cfg, gitlabAPI)
@@ -577,7 +578,7 @@ func TestCheckBadCreds(t *testing.T) {
}
func runHookServiceServer(t *testing.T, cfg config.Cfg) func() {
- return runHookServiceServerWithAPI(t, cfg, gitalyhook.GitlabAPIStub)
+ return runHookServiceServerWithAPI(t, cfg, gitlab.GitlabAPIStub)
}
type featureFlagAsserter struct {
@@ -615,7 +616,7 @@ func (svc featureFlagAsserter) PackObjectsHook(stream gitalypb.HookService_PackO
return svc.wrapped.PackObjectsHook(stream)
}
-func runHookServiceServerWithAPI(t *testing.T, cfg config.Cfg, gitlabAPI gitalyhook.GitlabAPI) func() {
+func runHookServiceServerWithAPI(t *testing.T, cfg config.Cfg, gitlabAPI gitlab.GitlabAPI) func() {
registry := backchannel.NewRegistry()
txManager := transaction.NewManager(cfg, registry)
hookManager := gitalyhook.NewManager(config.NewLocator(cfg), txManager, gitlabAPI, cfg)