Skip to content

Commit 68d2373

Browse files
committed
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 <[email protected]>
1 parent 64b8a81 commit 68d2373

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/dialer/dialer_windows.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
package dialer
1818

1919
import (
20+
"fmt"
2021
"net"
2122
"os"
23+
"path/filepath"
24+
"strings"
2225
"time"
2326

2427
winio "github.com/Microsoft/go-winio"
@@ -29,10 +32,16 @@ func isNoent(err error) bool {
2932
}
3033

3134
func dialer(address string, timeout time.Duration) (net.Conn, error) {
35+
address = strings.TrimPrefix(filepath.ToSlash(address), "npipe://")
3236
return winio.DialPipe(address, &timeout)
3337
}
3438

35-
// DialAddress returns the dial address
39+
// DialAddress returns the dial address with npipe:// prepended to the
40+
// provided address
3641
func DialAddress(address string) string {
42+
address = filepath.ToSlash(address)
43+
if !strings.HasPrefix(address, "npipe://") {
44+
address = fmt.Sprintf("npipe://%s", address)
45+
}
3746
return address
3847
}

0 commit comments

Comments
 (0)