Merge pull request #14206 from n1hility/win-machine-events

Add support for machine events on Windows
This commit is contained in:
openshift-ci[bot] 2022-05-12 21:49:19 +00:00 committed by GitHub
commit 9cf38a0afb
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 return err
case info.IsDir(): case info.IsDir():
return nil return nil
case info.Type() != os.ModeSocket: case !isUnixSocket(info):
return nil return nil
case !re.MatchString(info.Name()): case !re.MatchString(info.Name()):
return nil return nil

View File

@ -0,0 +1,12 @@
//go:build linux || ignore || aix || ignore || android || ignore || darwin || ignore || freebsd || ignore || hurd || ignore || illumos || ignore || ios || ignore || netbsd || ignore || openbsd || ignore || solaris
// +build linux ignore aix ignore android ignore darwin ignore freebsd ignore hurd ignore illumos ignore ios ignore netbsd ignore openbsd ignore 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 package util
import ( import (
"path/filepath"
"github.com/containers/storage/pkg/homedir"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -34,7 +37,12 @@ func GetRootlessPauseProcessPidPathGivenDir(unused string) (string, error) {
// GetRuntimeDir returns the runtime directory // GetRuntimeDir returns the runtime directory
func GetRuntimeDir() (string, error) { 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 // GetRootlessConfigHomeDir returns the config home directory when running as non root