solver: split platform specific code
Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
parent
a147f130ee
commit
d46a347781
@ -3,11 +3,8 @@ package solver
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"github.com/moby/buildkit/session"
|
||||
"github.com/moby/buildkit/session/sshforward"
|
||||
"google.golang.org/grpc"
|
||||
@ -41,20 +38,6 @@ func (sp *SocketProvider) CheckAgent(ctx context.Context, req *sshforward.CheckA
|
||||
return &sshforward.CheckAgentResponse{}, nil
|
||||
}
|
||||
|
||||
func dialStream(id string) (net.Conn, error) {
|
||||
switch {
|
||||
case strings.HasPrefix(id, unixPrefix):
|
||||
id = strings.TrimPrefix(id, unixPrefix)
|
||||
return net.DialTimeout("unix", id, time.Second)
|
||||
case strings.HasPrefix(id, npipePrefix):
|
||||
id = strings.TrimPrefix(id, npipePrefix)
|
||||
dur := time.Second
|
||||
return winio.DialPipe(id, &dur)
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid socket forward key %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func (sp *SocketProvider) ForwardAgent(stream sshforward.SSH_ForwardAgentServer) error {
|
||||
id := sshforward.DefaultID
|
||||
|
||||
|
20
solver/socketprovider_unix.go
Normal file
20
solver/socketprovider_unix.go
Normal file
@ -0,0 +1,20 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package solver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func dialStream(id string) (net.Conn, error) {
|
||||
if !strings.HasPrefix(id, unixPrefix) {
|
||||
return nil, fmt.Errorf("invalid socket forward key %s", id)
|
||||
}
|
||||
|
||||
id = strings.TrimPrefix(id, unixPrefix)
|
||||
return net.DialTimeout("unix", id, time.Second)
|
||||
}
|
14
solver/socketprovider_windows.go
Normal file
14
solver/socketprovider_windows.go
Normal file
@ -0,0 +1,14 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package solver
|
||||
|
||||
func dialStream(id string) (net.Conn, error) {
|
||||
if !strings.HasPrefix(id, unixPrefix) {
|
||||
return nil, fmt.Errorf("invalid socket forward key %s", id)
|
||||
}
|
||||
|
||||
id = strings.TrimPrefix(id, npipePrefix)
|
||||
dur := time.Second
|
||||
return winio.DialPipe(id, &dur)
|
||||
}
|
Reference in New Issue
Block a user