mirror of
https://github.com/containers/podman.git
synced 2025-06-22 01:48:54 +08:00
default to tunnel without ABISupport tag
When compiling a Linux binary without ABISupport, default to use the tunnel. The behaviour is expected in `podman-remote`. Also set a default for the remote flag so `podman-remote` works OOB. Signed-off-by: Valentin Rothberg <rothberg@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -22,6 +22,7 @@ const (
|
|||||||
var (
|
var (
|
||||||
podmanOptions entities.PodmanConfig
|
podmanOptions entities.PodmanConfig
|
||||||
podmanSync sync.Once
|
podmanSync sync.Once
|
||||||
|
abiSupport = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// PodmanConfig returns an entities.PodmanConfig built up from
|
// PodmanConfig returns an entities.PodmanConfig built up from
|
||||||
@ -39,23 +40,31 @@ func newPodmanConfig() {
|
|||||||
|
|
||||||
var mode entities.EngineMode
|
var mode entities.EngineMode
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin", "windows":
|
||||||
fallthrough
|
|
||||||
case "windows":
|
|
||||||
mode = entities.TunnelMode
|
mode = entities.TunnelMode
|
||||||
case "linux":
|
case "linux":
|
||||||
mode = entities.ABIMode
|
// Some linux clients might only be compiled without ABI
|
||||||
|
// support (e.g., podman-remote).
|
||||||
|
if abiSupport {
|
||||||
|
mode = entities.ABIMode
|
||||||
|
} else {
|
||||||
|
mode = entities.TunnelMode
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "%s is not a supported OS", runtime.GOOS)
|
fmt.Fprintf(os.Stderr, "%s is not a supported OS", runtime.GOOS)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// cobra.Execute() may not be called yet, so we peek at os.Args.
|
// Check if need to fallback to the tunnel mode if --remote is used.
|
||||||
for _, v := range os.Args {
|
if abiSupport && mode == entities.ABIMode {
|
||||||
// Prefix checking works because of how default EngineMode's
|
// cobra.Execute() may not be called yet, so we peek at os.Args.
|
||||||
// have been defined.
|
for _, v := range os.Args {
|
||||||
if strings.HasPrefix(v, "--remote") {
|
// Prefix checking works because of how default EngineMode's
|
||||||
mode = entities.TunnelMode
|
// have been defined.
|
||||||
|
if strings.HasPrefix(v, "--remote") {
|
||||||
|
mode = entities.TunnelMode
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
cmd/podman/registry/config_abi.go
Normal file
7
cmd/podman/registry/config_abi.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// +build ABISupport
|
||||||
|
|
||||||
|
package registry
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
abiSupport = true
|
||||||
|
}
|
7
cmd/podman/registry/config_tunnel.go
Normal file
7
cmd/podman/registry/config_tunnel.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// +build !ABISupport
|
||||||
|
|
||||||
|
package registry
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
abiSupport = false
|
||||||
|
}
|
@ -2,14 +2,18 @@ package registry
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/containers/libpod/pkg/domain/entities"
|
"github.com/containers/libpod/pkg/domain/entities"
|
||||||
"github.com/containers/libpod/pkg/domain/infra"
|
"github.com/containers/libpod/pkg/domain/infra"
|
||||||
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
|
"github.com/containers/libpod/pkg/util"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultAPIAddress is the default address of the REST socket
|
// DefaultRootAPIAddress is the default address of the REST socket
|
||||||
const DefaultAPIAddress = "unix:/run/podman/podman.sock"
|
const DefaultRootAPIAddress = "unix:/run/podman/podman.sock"
|
||||||
|
|
||||||
// DefaultVarlinkAddress is the default address of the varlink socket
|
// DefaultVarlinkAddress is the default address of the varlink socket
|
||||||
const DefaultVarlinkAddress = "unix:/run/podman/io.podman"
|
const DefaultVarlinkAddress = "unix:/run/podman/io.podman"
|
||||||
@ -98,3 +102,15 @@ func GetContextWithOptions() context.Context {
|
|||||||
func GetContext() context.Context {
|
func GetContext() context.Context {
|
||||||
return Context()
|
return Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DefaultAPIAddress() string {
|
||||||
|
if rootless.IsRootless() {
|
||||||
|
xdg, err := util.GetRuntimeDir()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warnf("Failed to get rootless runtime dir for DefaultAPIAddress: %s", err)
|
||||||
|
return DefaultRootAPIAddress
|
||||||
|
}
|
||||||
|
return "unix:" + filepath.Join(xdg, "podman", "podman.sock")
|
||||||
|
}
|
||||||
|
return DefaultRootAPIAddress
|
||||||
|
}
|
||||||
|
@ -208,7 +208,7 @@ func syslogHook() {
|
|||||||
|
|
||||||
func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) {
|
func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) {
|
||||||
// V2 flags
|
// V2 flags
|
||||||
flags.StringVarP(&opts.Uri, "remote", "r", "", "URL to access Podman service")
|
flags.StringVarP(&opts.Uri, "remote", "r", registry.DefaultAPIAddress(), "URL to access Podman service")
|
||||||
flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file")
|
flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file")
|
||||||
|
|
||||||
cfg := opts.Config
|
cfg := opts.Config
|
||||||
|
@ -139,6 +139,6 @@ func resolveApiURI(_url []string) (string, error) {
|
|||||||
case srvArgs.Varlink:
|
case srvArgs.Varlink:
|
||||||
return registry.DefaultVarlinkAddress, nil
|
return registry.DefaultVarlinkAddress, nil
|
||||||
default:
|
default:
|
||||||
return registry.DefaultAPIAddress, nil
|
return registry.DefaultRootAPIAddress, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user