Merge pull request #21420 from gordonmessmer/scp-no-mktemp

podman-image-scp: Load images without the use of a temporary file.
This commit is contained in:
openshift-merge-bot[bot] 2024-02-12 21:30:26 +00:00 committed by GitHub
commit 271a5199f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 7 deletions

View File

@ -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
} }