aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/machine/machine.go
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2022-06-17 14:47:26 -0400
committerAshley Cui <acui@redhat.com>2022-07-05 15:18:41 -0400
commit9d6efb34428811cc2b55b306733911cf20bd0b44 (patch)
tree887aaf6a2703035c893451740f393da0186aade7 /cmd/podman/machine/machine.go
parentb00e65aa9c071428579a55f91a92f3702765ed85 (diff)
downloadpodman-9d6efb34428811cc2b55b306733911cf20bd0b44.tar.gz
podman-9d6efb34428811cc2b55b306733911cf20bd0b44.tar.bz2
podman-9d6efb34428811cc2b55b306733911cf20bd0b44.zip
Podman machine info
Add podman machine info command, which displays infor about the machine host as well as version info. Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'cmd/podman/machine/machine.go')
-rw-r--r--cmd/podman/machine/machine.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/cmd/podman/machine/machine.go b/cmd/podman/machine/machine.go
index 5a8a06b9d..0618337cc 100644
--- a/cmd/podman/machine/machine.go
+++ b/cmd/podman/machine/machine.go
@@ -101,12 +101,6 @@ func resolveEventSock() ([]string, error) {
return []string{sock}, nil
}
- xdg, err := util.GetRuntimeDir()
- if err != nil {
- logrus.Warnf("Failed to get runtime dir, machine events will not be published: %s", err)
- return nil, nil
- }
-
re := regexp.MustCompile(`machine_events.*\.sock`)
sockPaths := make([]string, 0)
fn := func(path string, info os.DirEntry, err error) error {
@@ -125,8 +119,12 @@ func resolveEventSock() ([]string, error) {
sockPaths = append(sockPaths, path)
return nil
}
+ sockDir, err := eventSockDir()
+ if err != nil {
+ logrus.Warnf("Failed to get runtime dir, machine events will not be published: %s", err)
+ }
- if err := filepath.WalkDir(filepath.Join(xdg, "podman"), fn); err != nil {
+ if err := filepath.WalkDir(sockDir, fn); err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
@@ -135,6 +133,14 @@ func resolveEventSock() ([]string, error) {
return sockPaths, nil
}
+func eventSockDir() (string, error) {
+ xdg, err := util.GetRuntimeDir()
+ if err != nil {
+ return "", err
+ }
+ return filepath.Join(xdg, "podman"), nil
+}
+
func newMachineEvent(status events.Status, event events.Event) {
openEventSock.Do(initMachineEvents)