Merge pull request #14247 from n1hility/machine-event-win-41

[v4.1] Cherry-pick windows machine events
This commit is contained in:
OpenShift Merge Robot 2022-05-16 12:32:50 +02:00 committed by GitHub
commit cedbbfa543
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -115,7 +115,7 @@ func resolveEventSock() ([]string, error) {
return err
case info.IsDir():
return nil
case info.Type() != os.ModeSocket:
case !isUnixSocket(info):
return nil
case !re.MatchString(info.Name()):
return nil

View file

@ -0,0 +1,12 @@
//go:build linux || aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || netbsd || openbsd || solaris
// +build linux aix android darwin dragonfly freebsd hurd illumos ios netbsd openbsd solaris
package machine
import (
"os"
)
func isUnixSocket(file os.DirEntry) bool {
return file.Type()&os.ModeSocket != 0
}

View file

@ -0,0 +1,11 @@
package machine
import (
"os"
"strings"
)
func isUnixSocket(file os.DirEntry) bool {
// Assume a socket on Windows, since sock mode is not supported yet https://github.com/golang/go/issues/33357
return !file.Type().IsDir() && strings.HasSuffix(file.Name(), ".sock")
}

View file

@ -4,6 +4,9 @@
package util
import (
"path/filepath"
"github.com/containers/storage/pkg/homedir"
"github.com/pkg/errors"
)
@ -34,7 +37,12 @@ func GetRootlessPauseProcessPidPathGivenDir(unused string) (string, error) {
// GetRuntimeDir returns the runtime directory
func GetRuntimeDir() (string, error) {
return "", errors.New("this function is not implemented for windows")
data, err := homedir.GetDataHome()
if err != nil {
return "", err
}
runtimeDir := filepath.Join(data, "containers", "podman")
return runtimeDir, nil
}
// GetRootlessConfigHomeDir returns the config home directory when running as non root