diff --git a/pkg/options/options_suite_test.go b/pkg/options/options_suite_test.go index 151b9d0..f059530 100644 --- a/pkg/options/options_suite_test.go +++ b/pkg/options/options_suite_test.go @@ -22,12 +22,16 @@ var _ = Describe("Test parsing SSHArgs", func() { []string{"arg1", "arg2", "arg3"}, ), Entry("not split by whitespace inside quotes", - "arg1 arg2 ProxyCommand=\"cmd\"", - []string{"arg1", "arg2", "ProxyCommand=\"cmd\""}, + "arg1 arg2 ProxyCommand=\\\"arg1 arg2\\\"", + []string{"arg1", "arg2", "ProxyCommand=\"arg1 arg2\""}, ), Entry("not split by comma", - "arg1,arg2 ProxyCommand=\"cmd\"", - []string{"arg1,arg2", "ProxyCommand=\"cmd\""}, + "arg1,arg2", + []string{"arg1,arg2"}, + ), + Entry("real world example", + "ssh -i ~/yandex -o ProxyCommand=\\\"ssh -W %h:%p -i ~/yandex ubuntu@static-node-1.ydb-cluster.com\\\"", + []string{"ssh", "-i", "~/yandex", "-o", "ProxyCommand=\"ssh -W %h:%p -i ~/yandex ubuntu@static-node-1.ydb-cluster.com\""}, ), ) }) diff --git a/pkg/options/restart.go b/pkg/options/restart.go index 3682dd3..e6476db 100644 --- a/pkg/options/restart.go +++ b/pkg/options/restart.go @@ -162,8 +162,10 @@ func (o *RestartOptions) DefineFlags(fs *pflag.FlagSet) { fs.StringVar(&rawSSHUnparsedArgs, "ssh-args", "", `This argument will be used when ssh-ing to the nodes. It may be used to override the ssh command itself, ssh username or any additional arguments. -E.g.: - --ssh-args=pssh,-A,-J,,--yc-profile,`) +Double quotes are can be escaped with backward slash '\'. +Examples: +1) --ssh-args "pssh -A -J --yc-profile " +2) --ssh-args "ssh -o ProxyCommand=\"...\""`) fs.StringSliceVar(&o.Hosts, "hosts", o.Hosts, `Restart only specified hosts. You can specify a list of host FQDNs or a list of node ids, @@ -275,7 +277,7 @@ func parseSSHArgs(rawArgs string) []string { continue } - if unicode.IsSpace(rawRunes[i]) { + if unicode.IsSpace(rawRunes[i]) && !isInsideQuotes { if len(curArg) > 0 { args = append(args, string(curArg)) }