Fix windows compile for dialer package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
bba473aeb1
commit
fc08f019f3
@ -1,7 +1,6 @@
|
|||||||
package dialer
|
package dialer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,12 +12,6 @@ type dialResult struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialAddress returns the address with unix:// prepended to the
|
|
||||||
// provided address
|
|
||||||
func DialAddress(address string) string {
|
|
||||||
return fmt.Sprintf("unix://%s", address)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dialer returns a GRPC net.Conn connected to the provided address
|
// Dialer returns a GRPC net.Conn connected to the provided address
|
||||||
func Dialer(address string, timeout time.Duration) (net.Conn, error) {
|
func Dialer(address string, timeout time.Duration) (net.Conn, error) {
|
||||||
var (
|
var (
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
package dialer
|
package dialer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -10,6 +11,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DialAddress returns the address with unix:// prepended to the
|
||||||
|
// provided address
|
||||||
|
func DialAddress(address string) string {
|
||||||
|
return fmt.Sprintf("unix://%s", address)
|
||||||
|
}
|
||||||
|
|
||||||
func isNoent(err error) bool {
|
func isNoent(err error) bool {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if nerr, ok := err.(*net.OpError); ok {
|
if nerr, ok := err.(*net.OpError); ok {
|
||||||
|
@ -71,7 +71,7 @@ func TestExchangeBasic(t *testing.T) {
|
|||||||
cancel: cancel2,
|
cancel: cancel2,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
var received []Event
|
var received []events.Event
|
||||||
subscribercheck:
|
subscribercheck:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -72,11 +72,11 @@ type bundle struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ShimOpt specifies shim options for initialization and connection
|
// ShimOpt specifies shim options for initialization and connection
|
||||||
type ShimOpt func(*bundle, string, *runcopts.RuncOptions) (shim.Config, client.ClientOpt)
|
type ShimOpt func(*bundle, string, *runcopts.RuncOptions) (shim.Config, client.Opt)
|
||||||
|
|
||||||
// ShimRemote is a ShimOpt for connecting and starting a remote shim
|
// ShimRemote is a ShimOpt for connecting and starting a remote shim
|
||||||
func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) ShimOpt {
|
func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) ShimOpt {
|
||||||
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.ClientOpt) {
|
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
|
||||||
return b.shimConfig(ns, ropts),
|
return b.shimConfig(ns, ropts),
|
||||||
client.WithStart(shimBinary, b.shimAddress(ns), daemonAddress, cgroup, nonewns, debug, exitHandler)
|
client.WithStart(shimBinary, b.shimAddress(ns), daemonAddress, cgroup, nonewns, debug, exitHandler)
|
||||||
}
|
}
|
||||||
@ -84,14 +84,14 @@ func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, e
|
|||||||
|
|
||||||
// ShimLocal is a ShimOpt for using an in process shim implementation
|
// ShimLocal is a ShimOpt for using an in process shim implementation
|
||||||
func ShimLocal(exchange *exchange.Exchange) ShimOpt {
|
func ShimLocal(exchange *exchange.Exchange) ShimOpt {
|
||||||
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.ClientOpt) {
|
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
|
||||||
return b.shimConfig(ns, ropts), client.WithLocal(exchange)
|
return b.shimConfig(ns, ropts), client.WithLocal(exchange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShimConnect is a ShimOpt for connecting to an existing remote shim
|
// ShimConnect is a ShimOpt for connecting to an existing remote shim
|
||||||
func ShimConnect() ShimOpt {
|
func ShimConnect() ShimOpt {
|
||||||
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.ClientOpt) {
|
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
|
||||||
return b.shimConfig(ns, ropts), client.WithConnect(b.shimAddress(ns))
|
return b.shimConfig(ns, ropts), client.WithConnect(b.shimAddress(ns))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ import (
|
|||||||
|
|
||||||
var empty = &google_protobuf.Empty{}
|
var empty = &google_protobuf.Empty{}
|
||||||
|
|
||||||
// ClientOpt is an option for a shim client configuration
|
// Opt is an option for a shim client configuration
|
||||||
type ClientOpt func(context.Context, shim.Config) (shimapi.ShimClient, io.Closer, error)
|
type Opt func(context.Context, shim.Config) (shimapi.ShimClient, io.Closer, error)
|
||||||
|
|
||||||
// WithStart executes a new shim process
|
// WithStart executes a new shim process
|
||||||
func WithStart(binary, address, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) ClientOpt {
|
func WithStart(binary, address, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) Opt {
|
||||||
return func(ctx context.Context, config shim.Config) (_ shimapi.ShimClient, _ io.Closer, err error) {
|
return func(ctx context.Context, config shim.Config) (_ shimapi.ShimClient, _ io.Closer, err error) {
|
||||||
socket, err := newSocket(address)
|
socket, err := newSocket(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -164,7 +164,7 @@ func dialAddress(address string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithConnect connects to an existing shim
|
// WithConnect connects to an existing shim
|
||||||
func WithConnect(address string) ClientOpt {
|
func WithConnect(address string) Opt {
|
||||||
return func(ctx context.Context, config shim.Config) (shimapi.ShimClient, io.Closer, error) {
|
return func(ctx context.Context, config shim.Config) (shimapi.ShimClient, io.Closer, error) {
|
||||||
conn, err := connect(address, annonDialer)
|
conn, err := connect(address, annonDialer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -186,7 +186,7 @@ func WithLocal(publisher events.Publisher) func(context.Context, shim.Config) (s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new shim client
|
// New returns a new shim client
|
||||||
func New(ctx context.Context, config shim.Config, opt ClientOpt) (*Client, error) {
|
func New(ctx context.Context, config shim.Config, opt Opt) (*Client, error) {
|
||||||
s, c, err := opt(ctx, config)
|
s, c, err := opt(ctx, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user