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 <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu
2023-04-10 21:00:36 +08:00
parent 87ebe720f5
commit 46df30d9ba
+1 -11
View File
@@ -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)