summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/info.go4
-rw-r--r--pkg/domain/infra/abi/system.go10
-rw-r--r--pkg/util/utils.go23
3 files changed, 28 insertions, 9 deletions
diff --git a/pkg/api/handlers/libpod/info.go b/pkg/api/handlers/libpod/info.go
index 546609451..8868d563d 100644
--- a/pkg/api/handlers/libpod/info.go
+++ b/pkg/api/handlers/libpod/info.go
@@ -5,11 +5,13 @@ import (
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
+ "github.com/containers/podman/v3/pkg/domain/infra/abi"
)
func GetInfo(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
- info, err := runtime.Info()
+ containerEngine := abi.ContainerEngine{Libpod: runtime}
+ info, err := containerEngine.Info(r.Context())
if err != nil {
utils.InternalServerError(w, err)
return
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index f87f9e370..6319c1ab1 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -32,17 +32,11 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
if err != nil {
return nil, err
}
- xdg, err := util.GetRuntimeDir()
+
+ socketPath, err := util.SocketPath()
if err != nil {
return nil, err
}
- if len(xdg) == 0 {
- // If no xdg is returned, assume root socket
- xdg = "/run"
- }
-
- // Glue the socket path together
- socketPath := filepath.Join(xdg, "podman", "podman.sock")
rs := define.RemoteSocket{
Path: socketPath,
Exists: false,
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index bbaf72981..622fbde99 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -706,3 +706,26 @@ func IDtoolsToRuntimeSpec(idMaps []idtools.IDMap) (convertedIDMap []specs.LinuxI
}
return convertedIDMap
}
+
+var socketPath string
+
+func SetSocketPath(path string) {
+ socketPath = path
+}
+
+func SocketPath() (string, error) {
+ if socketPath != "" {
+ return socketPath, nil
+ }
+ xdg, err := GetRuntimeDir()
+ if err != nil {
+ return "", err
+ }
+ if len(xdg) == 0 {
+ // If no xdg is returned, assume root socket
+ xdg = "/run"
+ }
+
+ // Glue the socket path together
+ return filepath.Join(xdg, "podman", "podman.sock"), nil
+}