mirror of
https://github.com/containers/podman.git
synced 2025-07-01 00:01:02 +08:00
podman-image-scp: Load images without the use of a temporary file.
The default location for temporary files created by mktemp may not have enough space for an image. Use the new SSH functions which support an input reader to make the code simpler, more reliable, and more efficient. [NO NEW TESTS NEEDED] Signed-off-by: Gordon Messmer <gordon.messmer@gmail.com>
This commit is contained in:
@ -210,17 +210,13 @@ func LoadToRemote(dest entities.ImageScpOptions, localFile string, tag string, u
|
|||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteFile, err := ssh.Exec(&ssh.ConnectionExecOptions{Host: url.String(), Identity: iden, Port: port, User: url.User, Args: []string{"mktemp"}}, sshEngine)
|
input, err := os.Open(localFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
defer input.Close()
|
||||||
|
|
||||||
opts := ssh.ConnectionScpOptions{User: url.User, Identity: iden, Port: port, Source: localFile, Destination: "ssh://" + url.User.String() + "@" + url.Hostname() + ":" + remoteFile}
|
out, err := ssh.ExecWithInput(&ssh.ConnectionExecOptions{Host: url.String(), Identity: iden, Port: port, User: url.User, Args: []string{"podman", "image", "load"}}, sshEngine, input)
|
||||||
scpRep, err := ssh.Scp(&opts, sshEngine)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
out, err := ssh.Exec(&ssh.ConnectionExecOptions{Host: url.String(), Identity: iden, Port: port, User: url.User, Args: []string{"podman", "image", "load", "--input=" + scpRep + ";", "rm", scpRep}}, sshEngine)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user