summaryrefslogtreecommitdiff
path: root/go/internal/command/command.go
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-05 05:03:16 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-05 05:03:16 +0000
commitc577eb9ed8bd0336870f7a83302f70821d510169 (patch)
treeed7f7281633d97933e4465a2ac0f86d62c9a216e /go/internal/command/command.go
parented0460374a5ca13d9ea17c6a9c21151319b7fd53 (diff)
parent3b6f9f7583755e041e76142d7caf7716937907fa (diff)
downloadgitlab-shell-c577eb9ed8bd0336870f7a83302f70821d510169.tar.gz
Merge branch '181-migrate-gitlab-shell-checks-fallback' into 'master'
Support falling back to ruby version of checkers See merge request gitlab-org/gitlab-shell!318
Diffstat (limited to 'go/internal/command/command.go')
-rw-r--r--go/internal/command/command.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/go/internal/command/command.go b/go/internal/command/command.go
index a1dde42..27378aa 100644
--- a/go/internal/command/command.go
+++ b/go/internal/command/command.go
@@ -11,29 +11,40 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/uploadarchive"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/uploadpack"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/executable"
)
type Command interface {
Execute() error
}
-func New(arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (Command, error) {
- args, err := commandargs.Parse(arguments)
-
+func New(e *executable.Executable, arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (Command, error) {
+ args, err := commandargs.Parse(e, arguments)
if err != nil {
return nil, err
}
- if config.FeatureEnabled(string(args.CommandType)) {
- if cmd := buildCommand(args, config, readWriter); cmd != nil {
- return cmd, nil
- }
+ if cmd := buildCommand(e, args, config, readWriter); cmd != nil {
+ return cmd, nil
+ }
+
+ return &fallback.Command{Executable: e, RootDir: config.RootDir, Args: args}, nil
+}
+
+func buildCommand(e *executable.Executable, args commandargs.CommandArgs, config *config.Config, readWriter *readwriter.ReadWriter) Command {
+ switch e.Name {
+ case executable.GitlabShell:
+ return buildShellCommand(args.(*commandargs.Shell), config, readWriter)
}
- return &fallback.Command{RootDir: config.RootDir, Args: arguments}, nil
+ return nil
}
-func buildCommand(args *commandargs.CommandArgs, config *config.Config, readWriter *readwriter.ReadWriter) Command {
+func buildShellCommand(args *commandargs.Shell, config *config.Config, readWriter *readwriter.ReadWriter) Command {
+ if !config.FeatureEnabled(string(args.CommandType)) {
+ return nil
+ }
+
switch args.CommandType {
case commandargs.Discover:
return &discover.Command{Config: config, Args: args, ReadWriter: readWriter}