mirror of
https://github.com/containers/podman.git
synced 2025-06-07 07:45:34 +08:00
podman compose: enable machine socket connection
This can be enabled now. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -3,9 +3,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
"github.com/containers/podman/v5/pkg/machine/env"
|
"github.com/containers/podman/v5/pkg/machine/env"
|
||||||
@ -35,33 +37,34 @@ func getMachineConn(connectionURI string, parsedConnection *url.URL) (string, er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("parsing connection port: %w", err)
|
return "", fmt.Errorf("parsing connection port: %w", err)
|
||||||
}
|
}
|
||||||
for _, item := range machineList {
|
for _, mc := range machineList {
|
||||||
if connectionPort != item.SSH.Port {
|
if connectionPort != mc.SSH.Port {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
state, err := machineProvider.State(item, false)
|
state, err := machineProvider.State(mc, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if state != define.Running {
|
if state != define.Running {
|
||||||
return "", fmt.Errorf("machine %s is not running but in state %s", item.Name, state)
|
return "", fmt.Errorf("machine %s is not running but in state %s", mc.Name, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO This needs to be wired back in when all providers are complete
|
podmanSocket, podmanPipe, err := mc.ConnectionInfo(machineProvider.VMType())
|
||||||
// TODO Need someoone to plumb in the connection information below
|
if err != nil {
|
||||||
// if machineProvider.VMType() == define.WSLVirt || machineProvider.VMType() == define.HyperVVirt {
|
return "", err
|
||||||
// if info.ConnectionInfo.PodmanPipe == nil {
|
}
|
||||||
// return "", errors.New("pipe of machine is not set")
|
if machineProvider.VMType() == define.WSLVirt || machineProvider.VMType() == define.HyperVVirt {
|
||||||
// }
|
if podmanPipe == nil {
|
||||||
// return strings.Replace(info.ConnectionInfo.PodmanPipe.Path, `\\.\pipe\`, "npipe:////./pipe/", 1), nil
|
return "", errors.New("pipe of machine is not set")
|
||||||
// }
|
}
|
||||||
// if info.ConnectionInfo.PodmanSocket == nil {
|
return strings.Replace(podmanPipe.Path, `\\.\pipe\`, "npipe:////./pipe/", 1), nil
|
||||||
// return "", errors.New("socket of machine is not set")
|
}
|
||||||
// }
|
if podmanSocket == nil {
|
||||||
// return "unix://" + info.ConnectionInfo.PodmanSocket.Path, nil
|
return "", errors.New("socket of machine is not set")
|
||||||
return "", nil
|
}
|
||||||
|
return "unix://" + podmanSocket.Path, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("could not find a matching machine for connection %q", connectionURI)
|
return "", fmt.Errorf("could not find a matching machine for connection %q", connectionURI)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user