(shell string, args ...interface{})
| 129 | } |
| 130 | |
| 131 | func (c *SSHClient) Runf(shell string, args ...interface{}) (string, error) { |
| 132 | shell = c.SudoItem + " " + shell |
| 133 | shell = strings.ReplaceAll(shell, " && ", fmt.Sprintf(" && %s ", c.SudoItem)) |
| 134 | session, err := c.Client.NewSession() |
| 135 | if err != nil { |
| 136 | return "", err |
| 137 | } |
| 138 | defer session.Close() |
| 139 | buf, err := session.CombinedOutput(fmt.Sprintf(shell, args...)) |
| 140 | |
| 141 | return string(buf), err |
| 142 | } |
| 143 | |
| 144 | func (c *SSHClient) Close() { |
| 145 | if c.Client != nil { |
no test coverage detected