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-09-21 10:06:52 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-21 10:14:56 +0300
commit0ce8dca32cda0902d202bbd7f321db77237bd113 (patch)
tree110fab8d0b59fceeca0518eda6748df0b9165c5d
parent6cfa8f2dac97104cbfaa9140d59e834ab3560bc5 (diff)
gitaly-git2go: Remove "set-config" subcommand
While the "set-config" subcommand can in theory still be called when doing a zero-downtime upgrade given that its corresponding RPC still existed in this release, in practice the RPC wasn't ever called anymore. As a result, we can already drop the subcommand right now without having to fear any regressions.
-rw-r--r--cmd/gitaly-git2go/main.go1
-rw-r--r--cmd/gitaly-git2go/set_config.go67
-rw-r--r--internal/git2go/set_config.go50
3 files changed, 0 insertions, 118 deletions
diff --git a/cmd/gitaly-git2go/main.go b/cmd/gitaly-git2go/main.go
index 208dd5863..e940f6904 100644
--- a/cmd/gitaly-git2go/main.go
+++ b/cmd/gitaly-git2go/main.go
@@ -29,7 +29,6 @@ var subcommands = map[string]subcmd{
"revert": &revertSubcommand{},
"resolve": &resolveSubcommand{},
"submodule": &submoduleSubcommand{},
- "set_config": &setConfigSubcommand{},
}
func fatalf(format string, args ...interface{}) {
diff --git a/cmd/gitaly-git2go/set_config.go b/cmd/gitaly-git2go/set_config.go
deleted file mode 100644
index 79b104e6f..000000000
--- a/cmd/gitaly-git2go/set_config.go
+++ /dev/null
@@ -1,67 +0,0 @@
-//go:build static && system_libgit2
-// +build static,system_libgit2
-
-package main
-
-import (
- "context"
- "encoding/gob"
- "errors"
- "flag"
- "fmt"
- "io"
-
- "gitlab.com/gitlab-org/gitaly/v14/cmd/gitaly-git2go/git2goutil"
- "gitlab.com/gitlab-org/gitaly/v14/internal/git2go"
-)
-
-type setConfigSubcommand struct{}
-
-func (cmd *setConfigSubcommand) Flags() *flag.FlagSet {
- return flag.NewFlagSet("set_config", flag.ExitOnError)
-}
-
-func (cmd setConfigSubcommand) setConfig(request git2go.SetConfigCommand) error {
- if request.Repository == "" {
- return errors.New("missing repository")
- }
-
- git2goRepo, err := git2goutil.OpenRepository(request.Repository)
- if err != nil {
- return fmt.Errorf("open repository: %w", err)
- }
-
- conf, err := git2goRepo.Config()
- if err != nil {
- return fmt.Errorf("getting repository config: %w", err)
- }
-
- for key, entry := range request.Entries {
- switch v := entry.Value.(type) {
- case bool:
- err = conf.SetBool(key, v)
- case int32:
- err = conf.SetInt32(key, v)
- case string:
- err = conf.SetString(key, v)
- default:
- err = fmt.Errorf("unsupported value type: %T", entry.Value)
- }
- if err != nil {
- return fmt.Errorf("set config value for key %q: %w", key, err)
- }
- }
- return nil
-}
-
-func (cmd setConfigSubcommand) Run(_ context.Context, r io.Reader, w io.Writer) error {
- var request git2go.SetConfigCommand
- if err := gob.NewDecoder(r).Decode(&request); err != nil {
- return err
- }
-
- err := cmd.setConfig(request)
- return gob.NewEncoder(w).Encode(git2go.SetConfingResult{
- Error: git2go.SerializableError(err),
- })
-}
diff --git a/internal/git2go/set_config.go b/internal/git2go/set_config.go
deleted file mode 100644
index 0375189ea..000000000
--- a/internal/git2go/set_config.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package git2go
-
-import (
- "bytes"
- "context"
- "encoding/gob"
- "fmt"
-
- "gitlab.com/gitlab-org/gitaly/v14/internal/git/repository"
-)
-
-// ConfigEntry interface value with defined type.
-type ConfigEntry struct {
- Value interface{}
-}
-
-// SetConfigCommand contains parameters to perform setting of config entries.
-type SetConfigCommand struct {
- // Repository is the path to repository.
- Repository string `json:"repository"`
- // Entries key-value config entries.
- Entries map[string]ConfigEntry `json:"entries"`
-}
-
-// SetConfingResult contains results from set config action.
-type SetConfingResult struct {
- // Possible Error from git2go binary.
- Error error `json:"error"`
-}
-
-// SetConfig attempts to set all entries to config
-func (b Executor) SetConfig(ctx context.Context, repo repository.GitRepo, s SetConfigCommand) error {
- input := &bytes.Buffer{}
- if err := gob.NewEncoder(input).Encode(s); err != nil {
- return fmt.Errorf("resolve: %w", err)
- }
-
- stdout, err := b.run(ctx, repo, input, "set_config")
- if err != nil {
- return err
- }
-
- var response SetConfingResult
-
- if err := gob.NewDecoder(stdout).Decode(&response); err != nil {
- return fmt.Errorf("decodе response: %w", err)
- }
-
- return response.Error
-}