From 951b47d58383874a093018de8d38daf0628a3278 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sun, 3 Mar 2024 10:41:42 -0500 Subject: [PATCH] deadcode: SSH.StartProcess, SSH.createCmd, SSH.quote --- pkg/powershell/backend/ssh.go | 71 ++++++++++++++++------------------- 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/pkg/powershell/backend/ssh.go b/pkg/powershell/backend/ssh.go index 68c918280..bdaa6fdd7 100644 --- a/pkg/powershell/backend/ssh.go +++ b/pkg/powershell/backend/ssh.go @@ -3,12 +3,7 @@ package backend import ( - "fmt" "io" - "regexp" - "strings" - - "github.com/juju/errors" ) // sshSession exists so we don't create a hard dependency on crypto/ssh. @@ -25,45 +20,45 @@ type SSH struct { Session sshSession } -func (b *SSH) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error) { - stdin, err := b.Session.StdinPipe() - if err != nil { - return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdin stream") - } +// func (b *SSH) StartProcess(cmd string, args ...string) (Waiter, io.Writer, io.Reader, io.Reader, error) { +// stdin, err := b.Session.StdinPipe() +// if err != nil { +// return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdin stream") +// } - stdout, err := b.Session.StdoutPipe() - if err != nil { - return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdout stream") - } +// stdout, err := b.Session.StdoutPipe() +// if err != nil { +// return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stdout stream") +// } - stderr, err := b.Session.StderrPipe() - if err != nil { - return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stderr stream") - } +// stderr, err := b.Session.StderrPipe() +// if err != nil { +// return nil, nil, nil, nil, errors.Annotate(err, "Could not get hold of the SSH session's stderr stream") +// } - err = b.Session.Start(b.createCmd(cmd, args)) - if err != nil { - return nil, nil, nil, nil, errors.Annotate(err, "Could not spawn process via SSH") - } +// err = b.Session.Start(b.createCmd(cmd, args)) +// if err != nil { +// return nil, nil, nil, nil, errors.Annotate(err, "Could not spawn process via SSH") +// } - return b.Session, stdin, stdout, stderr, nil -} +// return b.Session, stdin, stdout, stderr, nil +// } -func (b *SSH) createCmd(cmd string, args []string) string { - parts := []string{cmd} - simple := regexp.MustCompile(`^[a-z0-9_/.~+-]+$`) +// func (b *SSH) createCmd(cmd string, args []string) string { +// parts := []string{cmd} +// simple := regexp.MustCompile(`^[a-z0-9_/.~+-]+$`) - for _, arg := range args { - if !simple.MatchString(arg) { - arg = b.quote(arg) - } +// for _, arg := range args { +// if !simple.MatchString(arg) { +// arg = b.quote(arg) +// } - parts = append(parts, arg) - } +// parts = append(parts, arg) +// } - return strings.Join(parts, " ") -} +// return strings.Join(parts, " ") +// } -func (b *SSH) quote(s string) string { - return fmt.Sprintf(`"%s"`, s) -} +// func (b *SSH) quote(s string) string { +// return fmt.Sprintf(`"%s"`, s) +// }