mirror of https://github.com/containers/podman.git
podman compose: correctly accept --connection/--url
Make the logic here much simpler, we already pass all the conection info before so just use the parsed URL here. Fixes #20943 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
6d3571dcf5
commit
3cada04099
|
@ -108,10 +108,8 @@ func composeDockerHost() (string, error) {
|
||||||
return registry.DefaultAPIAddress(), nil
|
return registry.DefaultAPIAddress(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO need to add support for --connection and --url
|
conf := registry.PodmanConfig()
|
||||||
connection, err := registry.PodmanConfig().ContainersConfDefaultsRO.GetConnection("", true)
|
if conf.URI == "" {
|
||||||
if err != nil {
|
|
||||||
logrus.Info(err)
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
// If no default connection is set on Linux or FreeBSD,
|
// If no default connection is set on Linux or FreeBSD,
|
||||||
// we just use the local socket by default - just as
|
// we just use the local socket by default - just as
|
||||||
|
@ -126,20 +124,20 @@ func composeDockerHost() (string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedConnection, err := url.Parse(connection.URI)
|
parsedConnection, err := url.Parse(conf.URI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("preparing connection to remote machine: %w", err)
|
return "", fmt.Errorf("preparing connection to remote machine: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the default connection does not point to a `podman
|
// If the default connection does not point to a `podman
|
||||||
// machine`, we cannot use a local path and need to use SSH.
|
// machine`, we cannot use a local path and need to use SSH.
|
||||||
if !connection.IsMachine {
|
if !conf.MachineMode {
|
||||||
// Compose doesn't like paths, so we optimistically
|
// Compose doesn't like paths, so we optimistically
|
||||||
// assume the presence of a Docker socket on the remote
|
// assume the presence of a Docker socket on the remote
|
||||||
// machine which is the case for podman machines.
|
// machine which is the case for podman machines.
|
||||||
return strings.TrimSuffix(connection.URI, parsedConnection.Path), nil
|
return strings.TrimSuffix(conf.URI, parsedConnection.Path), nil
|
||||||
}
|
}
|
||||||
uri, err := getMachineConn(connection, parsedConnection)
|
uri, err := getMachineConn(conf.URI, parsedConnection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("get machine connection URI: %w", err)
|
return "", fmt.Errorf("get machine connection URI: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,13 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
|
||||||
"github.com/containers/podman/v5/pkg/machine"
|
"github.com/containers/podman/v5/pkg/machine"
|
||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
"github.com/containers/podman/v5/pkg/machine/provider"
|
"github.com/containers/podman/v5/pkg/machine/provider"
|
||||||
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getMachineConn(connection *config.Connection, parsedConnection *url.URL) (string, error) {
|
func getMachineConn(connectionURI string, parsedConnection *url.URL) (string, error) {
|
||||||
machineProvider, err := provider.Get()
|
machineProvider, err := provider.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("getting machine provider: %w", err)
|
return "", fmt.Errorf("getting machine provider: %w", err)
|
||||||
|
@ -64,6 +63,5 @@ func getMachineConn(connection *config.Connection, parsedConnection *url.URL) (s
|
||||||
// return "unix://" + info.ConnectionInfo.PodmanSocket.Path, nil
|
// return "unix://" + info.ConnectionInfo.PodmanSocket.Path, nil
|
||||||
return "", nil
|
return "", 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", connection.URI)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func getMachineConn(connection *config.Connection, parsedConnection *url.URL) (string, error) {
|
func getMachineConn(connection string, parsedConnection *url.URL) (string, error) {
|
||||||
return "", errors.New("podman machine not supported on this architecture")
|
return "", errors.New("podman machine not supported on this architecture")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue