Merge pull request #6486 from baude/v2infoaddsocket
add socket information to podman info
This commit is contained in:
commit
9d138724ab
|
|
@ -71,6 +71,9 @@ host:
|
||||||
commit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
|
commit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
|
||||||
spec: 1.0.1-dev
|
spec: 1.0.1-dev
|
||||||
os: linux
|
os: linux
|
||||||
|
remoteSocket:
|
||||||
|
exists: false
|
||||||
|
path: /run/user/1000/podman/podman.sock
|
||||||
rootless: true
|
rootless: true
|
||||||
slirp4netns:
|
slirp4netns:
|
||||||
executable: /bin/slirp4netns
|
executable: /bin/slirp4netns
|
||||||
|
|
@ -179,6 +182,10 @@ Run podman info with JSON formatted response:
|
||||||
"version": "runc version 1.0.0-rc8+dev\ncommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657\nspec: 1.0.1-dev"
|
"version": "runc version 1.0.0-rc8+dev\ncommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657\nspec: 1.0.1-dev"
|
||||||
},
|
},
|
||||||
"os": "linux",
|
"os": "linux",
|
||||||
|
"remoteSocket": {
|
||||||
|
"path": "/run/user/1000/podman/podman.sock",
|
||||||
|
"exists": false
|
||||||
|
},
|
||||||
"rootless": true,
|
"rootless": true,
|
||||||
"slirp4netns": {
|
"slirp4netns": {
|
||||||
"executable": "/bin/slirp4netns",
|
"executable": "/bin/slirp4netns",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ type HostInfo struct {
|
||||||
MemTotal int64 `json:"memTotal"`
|
MemTotal int64 `json:"memTotal"`
|
||||||
OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"`
|
OCIRuntime *OCIRuntimeInfo `json:"ociRuntime"`
|
||||||
OS string `json:"os"`
|
OS string `json:"os"`
|
||||||
|
RemoteSocket *RemoteSocket `json:"remoteSocket,omitempty"`
|
||||||
Rootless bool `json:"rootless"`
|
Rootless bool `json:"rootless"`
|
||||||
RuntimeInfo map[string]interface{} `json:"runtimeInfo,omitempty"`
|
RuntimeInfo map[string]interface{} `json:"runtimeInfo,omitempty"`
|
||||||
Slirp4NetNS SlirpInfo `json:"slirp4netns,omitempty"`
|
Slirp4NetNS SlirpInfo `json:"slirp4netns,omitempty"`
|
||||||
|
|
@ -36,6 +37,12 @@ type HostInfo struct {
|
||||||
Linkmode string `json:"linkmode"`
|
Linkmode string `json:"linkmode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoteSocket describes information about the API socket
|
||||||
|
type RemoteSocket struct {
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
Exists bool `json:"exists,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// SlirpInfo describes the slirp exectuable that
|
// SlirpInfo describes the slirp exectuable that
|
||||||
// is being being used.
|
// is being being used.
|
||||||
type SlirpInfo struct {
|
type SlirpInfo struct {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,38 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
|
func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
|
||||||
return ic.Libpod.Info()
|
info, err := ic.Libpod.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
xdg, err := util.GetRuntimeDir()
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the socket exists
|
||||||
|
if fi, err := os.Stat(socketPath); err == nil {
|
||||||
|
if fi.Mode()&os.ModeSocket != 0 {
|
||||||
|
rs.Exists = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO
|
||||||
|
// it was suggested future versions of this could perform
|
||||||
|
// a ping on the socket for greater confidence the socket is
|
||||||
|
// actually active.
|
||||||
|
info.Host.RemoteSocket = &rs
|
||||||
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command) error {
|
func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue