Skip to content

Commit

Permalink
Issue #873 Add runPrivate parameter to runSSHCommandFromDriver method
Browse files Browse the repository at this point in the history
Changed the runSSHCommandFromDriver method signature to accomodate
not to show a command and it's output in debug log if that is true
from caller functions/method.
  • Loading branch information
praveenkumar committed Dec 10, 2019
1 parent 0743c40 commit 871cc9b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/crc/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,29 @@ func CreateRunnerWithPrivateKey(driver drivers.Driver, privateKey string) *SSHRu

// Create a host using the driver's config
func (runner *SSHRunner) Run(command string) (string, error) {
return runner.runSSHCommandFromDriver(command)
return runner.runSSHCommandFromDriver(command, false)
}

func (runner *SSHRunner) SetPrivateKeyPath(path string) {
runner.privateSSHKey = path
}

func (runner *SSHRunner) runSSHCommandFromDriver(command string) (string, error) {
func (runner *SSHRunner) runSSHCommandFromDriver(command string, runPrivate bool) (string, error) {
client, err := drivers.GetSSHClientFromDriver(runner.driver, runner.privateSSHKey)
if err != nil {
return "", err
}

logging.Debugf("About to run SSH command:\n%s", command)
if runPrivate {
logging.Debugf("About to run SSH command with hidden output")
} else {
logging.Debugf("About to run SSH command:\n%s", command)
}

output, err := client.Output(command)
logging.Debugf("SSH cmd err, output: %v: %s", err, output)
if !runPrivate {
logging.Debugf("SSH cmd err, output: %v: %s", err, output)
}
if err != nil {
return "", fmt.Errorf(`ssh command error:
command : %s
Expand Down

0 comments on commit 871cc9b

Please sign in to comment.