diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-19 09:56:19 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-20 09:48:15 +0300 |
commit | 2faa07439b1ceaa2d49cfc125b68c9ca058e009c (patch) | |
tree | b6511222b6df13d64a3ae525b94a6868b587179d | |
parent | 06bba2577b74dc49364d7aee9c540bd8ff4d6ac7 (diff) |
git2go: Implement set-config on top of the executor
We're about to extend dependencies required to run gitaly-git2go
subcommands, which will make calling them tedious. This commit thus
refactors the set-config subcommand to be implemented on top of the
`Executor` structure, which encapsulates all required dependencies and
thus avoids the additional complexity.
-rw-r--r-- | internal/git2go/set_config.go | 8 | ||||
-rw-r--r-- | internal/gitaly/service/repository/config.go | 3 | ||||
-rw-r--r-- | internal/gitaly/service/repository/server.go | 3 |
3 files changed, 7 insertions, 7 deletions
diff --git a/internal/git2go/set_config.go b/internal/git2go/set_config.go index 9b95fb319..fadb71817 100644 --- a/internal/git2go/set_config.go +++ b/internal/git2go/set_config.go @@ -5,8 +5,6 @@ import ( "context" "encoding/gob" "fmt" - - "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" ) // ConfigEntry interface value with defined type. @@ -28,14 +26,14 @@ type SetConfingResult struct { Error error `json:"error"` } -// Run attempts to set all entries to config -func (s SetConfigCommand) Run(ctx context.Context, cfg config.Cfg) error { +// SetConfig attempts to set all entries to config +func (b Executor) SetConfig(ctx context.Context, s SetConfigCommand) error { input := &bytes.Buffer{} if err := gob.NewEncoder(input).Encode(s); err != nil { return fmt.Errorf("resolve: %w", err) } - stdout, err := run(ctx, BinaryPath(cfg.BinDir), input, "set_config") + stdout, err := run(ctx, b.binaryPath, input, "set_config") if err != nil { return err } diff --git a/internal/gitaly/service/repository/config.go b/internal/gitaly/service/repository/config.go index ab3b495bf..6fbf0f21d 100644 --- a/internal/gitaly/service/repository/config.go +++ b/internal/gitaly/service/repository/config.go @@ -133,8 +133,7 @@ func (s *server) setConfigGit2Go(ctx context.Context, req *gitalypb.SetConfigReq return nil, helper.ErrInternalf("preimage vote on config: %v", err) } - cmd := git2go.SetConfigCommand{Repository: path, Entries: entries} - if err := cmd.Run(ctx, s.cfg); err != nil { + if err := s.git2go.SetConfig(ctx, git2go.SetConfigCommand{Repository: path, Entries: entries}); err != nil { return nil, status.Errorf(codes.Internal, "SetConfig git2go error") } diff --git a/internal/gitaly/service/repository/server.go b/internal/gitaly/service/repository/server.go index eb6b71750..7535c2ea7 100644 --- a/internal/gitaly/service/repository/server.go +++ b/internal/gitaly/service/repository/server.go @@ -6,6 +6,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v14/internal/git/repository" + "gitlab.com/gitlab-org/gitaly/v14/internal/git2go" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/rubyserver" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction" @@ -24,6 +25,7 @@ type server struct { binDir string loggingCfg config.Logging catfileCache catfile.Cache + git2go git2go.Executor } // NewServer creates a new instance of a gRPC repo server @@ -48,6 +50,7 @@ func NewServer( binDir: cfg.BinDir, loggingCfg: cfg.Logging, catfileCache: catfileCache, + git2go: git2go.NewExecutor(cfg), } } |