diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-02-10 11:09:15 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-02-11 00:51:30 +0300 |
commit | 2a2a887d9f3e09c552704595d8db1fc3923c33fb (patch) | |
tree | 95b0bdfb99acf9d7a89e5ba7943148ae56bc32c7 | |
parent | a8439e91f58b5962ade33d15763ddbcfe2dec9a5 (diff) |
Break dependency on config.Config in diff
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r-- | internal/gitaly/service/diff/find_changed_paths.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/diff/server.go | 5 | ||||
-rw-r--r-- | internal/gitaly/service/diff/testhelper_test.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/register.go | 2 |
4 files changed, 8 insertions, 5 deletions
diff --git a/internal/gitaly/service/diff/find_changed_paths.go b/internal/gitaly/service/diff/find_changed_paths.go index 64e621811..172e11006 100644 --- a/internal/gitaly/service/diff/find_changed_paths.go +++ b/internal/gitaly/service/diff/find_changed_paths.go @@ -10,7 +10,6 @@ import ( "github.com/golang/protobuf/proto" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/localrepo" - "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc/codes" @@ -136,7 +135,7 @@ func (s *server) validateFindChangedPathsRequestParams(ctx context.Context, in * return err } - gitRepo := localrepo.New(repo, config.Config) + gitRepo := localrepo.New(repo, s.cfg) for _, commit := range in.GetCommits() { if commit == "" { diff --git a/internal/gitaly/service/diff/server.go b/internal/gitaly/service/diff/server.go index 3754acd83..48faf8db1 100644 --- a/internal/gitaly/service/diff/server.go +++ b/internal/gitaly/service/diff/server.go @@ -2,6 +2,7 @@ package diff import ( "gitlab.com/gitlab-org/gitaly/internal/git" + "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/storage" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" ) @@ -10,14 +11,16 @@ const msgSizeThreshold = 5 * 1024 type server struct { MsgSizeThreshold int + cfg config.Cfg locator storage.Locator gitCmdFactory git.CommandFactory } // NewServer creates a new instance of a gRPC DiffServer -func NewServer(locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.DiffServiceServer { +func NewServer(cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.DiffServiceServer { return &server{ MsgSizeThreshold: msgSizeThreshold, + cfg: cfg, locator: locator, gitCmdFactory: gitCmdFactory, } diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go index a4d41ccdd..3a1ad4586 100644 --- a/internal/gitaly/service/diff/testhelper_test.go +++ b/internal/gitaly/service/diff/testhelper_test.go @@ -33,7 +33,8 @@ func runDiffServer(t *testing.T) (*grpc.Server, string) { t.Fatal(err) } - gitalypb.RegisterDiffServiceServer(server, NewServer(config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config))) + cfg := config.Config + gitalypb.RegisterDiffServiceServer(server, NewServer(cfg, config.NewLocator(cfg), git.NewExecCommandFactory(cfg))) reflection.Register(server) go server.Serve(listener) diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go index 961af66f2..85984af7d 100644 --- a/internal/gitaly/service/register.go +++ b/internal/gitaly/service/register.go @@ -70,7 +70,7 @@ func RegisterAll( gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer, locator, gitCmdFactory)) gitalypb.RegisterCleanupServiceServer(grpcServer, cleanup.NewServer(cfg, gitCmdFactory)) gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer(cfg, locator, gitCmdFactory)) - gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(locator, gitCmdFactory)) + gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(cfg, locator, gitCmdFactory)) gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer(locator)) gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator, conns, gitCmdFactory)) gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator, gitCmdFactory)) |