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 <profnandaa@gmail.com>
This commit is contained in:
parent
6ed8f01aa1
commit
8e91edb71e
@ -17,8 +17,11 @@
|
|||||||
package dialer
|
package dialer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
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) {
|
func dialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||||
|
address = strings.TrimPrefix(filepath.ToSlash(address), "npipe://")
|
||||||
return winio.DialPipe(address, &timeout)
|
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 {
|
func DialAddress(address string) string {
|
||||||
|
address = filepath.ToSlash(address)
|
||||||
|
if !strings.HasPrefix(address, "npipe://") {
|
||||||
|
address = fmt.Sprintf("npipe://%s", address)
|
||||||
|
}
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user