From aab85f3600caf04b491d6ca4fc3f0f004d9e3fc0 Mon Sep 17 00:00:00 2001 From: Patrick Bajao Date: Mon, 29 Jul 2019 14:33:01 +0800 Subject: Support falling back to ruby version of checkers Rename the ruby scripts to have `-ruby` suffix and add a symlink for both to `./gitlab-shell`. The executable name will be used to determine how args will be parsed. For now, we only parse the arguments for gitlab-shell commands. If the executable is `gitlab-shell-authorized-keys-check` or `gitlab-shell-authorized-principals-check`, it'll always fallback to the ruby version. Ruby specs test the ruby script, the fallback from go to ruby and go implementation of both (still pending). --- go/internal/command/fallback/fallback_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'go/internal/command/fallback/fallback_test.go') diff --git a/go/internal/command/fallback/fallback_test.go b/go/internal/command/fallback/fallback_test.go index afd752b..91dcb53 100644 --- a/go/internal/command/fallback/fallback_test.go +++ b/go/internal/command/fallback/fallback_test.go @@ -6,6 +6,8 @@ import ( "testing" "github.com/stretchr/testify/require" + + "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs" ) type fakeExec struct { @@ -18,8 +20,21 @@ type fakeExec struct { Env []string } +type FakeCommandArgs struct { + executable commandargs.Executable + arguments []string +} + +func (f *FakeCommandArgs) Executable() commandargs.Executable { + return f.executable +} + +func (f *FakeCommandArgs) Arguments() []string { + return f.arguments +} + var ( - fakeArgs = []string{"./test", "foo", "bar"} + fakeArgs = &FakeCommandArgs{executable: commandargs.GitlabShell, arguments: []string{"foo", "bar"}} ) func (f *fakeExec) Exec(filename string, args []string, env []string) error { -- cgit v1.2.1