diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-21 10:06:52 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-21 10:14:56 +0300 |
commit | 0ce8dca32cda0902d202bbd7f321db77237bd113 (patch) | |
tree | 110fab8d0b59fceeca0518eda6748df0b9165c5d /cmd | |
parent | 6cfa8f2dac97104cbfaa9140d59e834ab3560bc5 (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.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-git2go/main.go | 1 | ||||
-rw-r--r-- | cmd/gitaly-git2go/set_config.go | 67 |
2 files changed, 0 insertions, 68 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), - }) -} |