From 46df30d9baaafcce44aed454255d44750bab93c9 Mon Sep 17 00:00:00 2001 From: "Bo-Yi.Wu" Date: Mon, 10 Apr 2023 21:00:36 +0800 Subject: [PATCH] refactor: refactor system type checks in SSH commands - Remove `uname` check for system type from `removeAllDestFile` function. - Add `ver` check for SSH command in `Exec` function. - Remove `uname` check for system type from `Exec` function. Signed-off-by: Bo-Yi.Wu --- plugin.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/plugin.go b/plugin.go index 81a8927..acce0f3 100644 --- a/plugin.go +++ b/plugin.go @@ -169,11 +169,6 @@ func (p *Plugin) removeAllDestFile() error { systemType = "windows" } - _, _, _, err = ssh.Run("uname", p.Config.CommandTimeout) - if err == nil { - systemType = "unix" - } - // remove tar file err = p.removeDestFile(systemType, ssh) if err != nil { @@ -309,17 +304,12 @@ func (p *Plugin) Exec() error { }, } - _, _, _, err := ssh.Run("ver", p.Config.CommandTimeout) systemType := "unix" + _, _, _, err := ssh.Run("ver", p.Config.CommandTimeout) if err == nil { systemType = "windows" } - _, _, _, err = ssh.Run("uname", p.Config.CommandTimeout) - if err == nil { - systemType = "unix" - } - // upload file to the tmp path p.DestFile = fmt.Sprintf("%s%s", p.Config.TarTmpPath, p.DestFile)