From 8e91edb71e29c84333cca20894991d244144696f Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Tue, 21 Nov 2023 23:45:08 -0800 Subject: [PATCH] fix(pkg/dialer): minor fix on dialer function for windows This commit fixes the dialer function to make sure that "npipe://" prefix is trimmed, just like the way it is done in the Unix counterpart, `./dialer_unix.go:50` This will also unblock some downstream work going on in buildkit; setting up integration tests to run on Windows. Signed-off-by: Anthony Nandaa --- pkg/dialer/dialer_windows.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/dialer/dialer_windows.go b/pkg/dialer/dialer_windows.go index 4dd296ebc3e5..cf74cc0d82e5 100644 --- a/pkg/dialer/dialer_windows.go +++ b/pkg/dialer/dialer_windows.go @@ -17,8 +17,11 @@ package dialer import ( + "fmt" "net" "os" + "path/filepath" + "strings" "time" winio "github.com/Microsoft/go-winio" @@ -29,10 +32,16 @@ func isNoent(err error) bool { } func dialer(address string, timeout time.Duration) (net.Conn, error) { + address = strings.TrimPrefix(filepath.ToSlash(address), "npipe://") return winio.DialPipe(address, &timeout) } -// DialAddress returns the dial address +// DialAddress returns the dial address with npipe:// prepended to the +// provided address func DialAddress(address string) string { + address = filepath.ToSlash(address) + if !strings.HasPrefix(address, "npipe://") { + address = fmt.Sprintf("npipe://%s", address) + } return address }