summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images/scp.go12
-rw-r--r--cmd/podman/system/connection/add.go7
-rw-r--r--cmd/podman/system/connection/shared.go9
3 files changed, 9 insertions, 19 deletions
diff --git a/cmd/podman/images/scp.go b/cmd/podman/images/scp.go
index 8402d9a10..67a531e6b 100644
--- a/cmd/podman/images/scp.go
+++ b/cmd/podman/images/scp.go
@@ -168,7 +168,7 @@ func loadToRemote(localFile string, tag string, url *urlP.URL, iden string) (str
n, err := scpD.CopyTo(dial, localFile, remoteFile)
if err != nil {
- errOut := (strconv.Itoa(int(n)) + " Bytes copied before error")
+ errOut := strconv.Itoa(int(n)) + " Bytes copied before error"
return " ", errors.Wrapf(err, errOut)
}
run := ""
@@ -181,7 +181,7 @@ func loadToRemote(localFile string, tag string, url *urlP.URL, iden string) (str
if err != nil {
return "", err
}
- return strings.TrimSuffix(out, "\n"), nil
+ return strings.TrimSuffix(string(out), "\n"), nil
}
// saveToRemote takes image information and remote connection information. it connects to the specified client
@@ -207,7 +207,7 @@ func saveToRemote(image, localFile string, tag string, uri *urlP.URL, iden strin
n, err := scpD.CopyFrom(dial, remoteFile, localFile)
connection.ExecRemoteCommand(dial, "rm "+remoteFile)
if err != nil {
- errOut := (strconv.Itoa(int(n)) + " Bytes copied before error")
+ errOut := strconv.Itoa(int(n)) + " Bytes copied before error"
return errors.Wrapf(err, errOut)
}
return nil
@@ -221,11 +221,7 @@ func makeRemoteFile(dial *ssh.Client) (string, error) {
if err != nil {
return "", err
}
- remoteFile = strings.TrimSuffix(remoteFile, "\n")
- if err != nil {
- return "", err
- }
- return remoteFile, nil
+ return strings.TrimSuffix(string(remoteFile), "\n"), nil
}
// createConnections takes a boolean determining which ssh client to dial
diff --git a/cmd/podman/system/connection/add.go b/cmd/podman/system/connection/add.go
index 290b3c245..ee237d7d0 100644
--- a/cmd/podman/system/connection/add.go
+++ b/cmd/podman/system/connection/add.go
@@ -226,12 +226,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL, iden string) (string, error) {
if v, found := os.LookupEnv("PODMAN_BINARY"); found {
podman = v
}
- run := podman + " info --format=json"
- out, err := ExecRemoteCommand(dial, run)
- if err != nil {
- return "", err
- }
- infoJSON, err := json.Marshal(out)
+ infoJSON, err := ExecRemoteCommand(dial, podman+" info --format=json")
if err != nil {
return "", err
}
diff --git a/cmd/podman/system/connection/shared.go b/cmd/podman/system/connection/shared.go
index 3fd7c59fb..714ae827d 100644
--- a/cmd/podman/system/connection/shared.go
+++ b/cmd/podman/system/connection/shared.go
@@ -9,10 +9,10 @@ import (
// ExecRemoteCommand takes a ssh client connection and a command to run and executes the
// command on the specified client. The function returns the Stdout from the client or the Stderr
-func ExecRemoteCommand(dial *ssh.Client, run string) (string, error) {
+func ExecRemoteCommand(dial *ssh.Client, run string) ([]byte, error) {
sess, err := dial.NewSession() // new ssh client session
if err != nil {
- return "", err
+ return nil, err
}
defer sess.Close()
@@ -21,8 +21,7 @@ func ExecRemoteCommand(dial *ssh.Client, run string) (string, error) {
sess.Stdout = &buffer // output from client funneled into buffer
sess.Stderr = &bufferErr // err form client funneled into buffer
if err := sess.Run(run); err != nil { // run the command on the ssh client
- return "", errors.Wrapf(err, bufferErr.String())
+ return nil, errors.Wrapf(err, bufferErr.String())
}
- out := buffer.String() // output from command
- return out, nil
+ return buffer.Bytes(), nil
}