Skip to content

Commit

Permalink
podman-image-scp: Load images without the use of a temporary file.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gordonmessmer committed Feb 12, 2024
1 parent a7b20b6 commit eb8428d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/domain/utils/scp.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,13 @@ func LoadToRemote(dest entities.ImageScpOptions, localFile string, tag string, u
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 {
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}
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)
out, err := ssh.ExecWithInput(&ssh.ConnectionExecOptions{Host: url.String(), Identity: iden, Port: port, User: url.User, Args: []string{"podman", "image", "load"}}, sshEngine, input)
if err != nil {
return "", "", err
}
Expand Down

0 comments on commit eb8428d

Please sign in to comment.