mirror of
https://github.com/containers/podman.git
synced 2026-10-25 19:29:32 -04:00
Merge pull request #21583 from Luap99/scp-port
image scp: don't require port for ssh URL
This commit is contained in:
1 file changed
+16
-6
+16
-6
@@ -205,9 +205,14 @@ func LoginUser(user string) (*exec.Cmd, error) {
|
||||
// and copies the saved image dir over to the remote host and then loads it onto the machine
|
||||
// returns a string containing output or an error
|
||||
func LoadToRemote(dest entities.ImageScpOptions, localFile string, tag string, url *url.URL, iden string, sshEngine ssh.EngineMode) (string, string, error) {
|
||||
port, err := strconv.Atoi(url.Port())
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
port := 0
|
||||
urlPort := url.Port()
|
||||
if urlPort != "" {
|
||||
var err error
|
||||
port, err = strconv.Atoi(url.Port())
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
}
|
||||
|
||||
input, err := os.Open(localFile)
|
||||
@@ -246,9 +251,14 @@ func SaveToRemote(image, localFile string, tag string, uri *url.URL, iden string
|
||||
return fmt.Errorf("renaming of an image is currently not supported: %w", define.ErrInvalidArg)
|
||||
}
|
||||
|
||||
port, err := strconv.Atoi(uri.Port())
|
||||
if err != nil {
|
||||
return err
|
||||
port := 0
|
||||
urlPort := uri.Port()
|
||||
if urlPort != "" {
|
||||
var err error
|
||||
port, err = strconv.Atoi(uri.Port())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
remoteFile, err := ssh.Exec(&ssh.ConnectionExecOptions{Host: uri.String(), Identity: iden, Port: port, User: uri.User, Args: []string{"mktemp"}}, sshEngine)
|
||||
|
||||
Reference in new issue
Block a user