diff --git a/dialer/dialer.go b/dialer/dialer.go index b1a5a3c28..65af69f9b 100644 --- a/dialer/dialer.go +++ b/dialer/dialer.go @@ -1,7 +1,6 @@ package dialer import ( - "fmt" "net" "time" @@ -13,12 +12,6 @@ type dialResult struct { 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 func Dialer(address string, timeout time.Duration) (net.Conn, error) { var ( diff --git a/dialer/dialer_unix.go b/dialer/dialer_unix.go index 3a078d4bd..7f8d43b03 100644 --- a/dialer/dialer_unix.go +++ b/dialer/dialer_unix.go @@ -3,6 +3,7 @@ package dialer import ( + "fmt" "net" "os" "strings" @@ -10,6 +11,12 @@ import ( "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 { if err != nil { if nerr, ok := err.(*net.OpError); ok { diff --git a/events/exchange/exchange_test.go b/events/exchange/exchange_test.go index 9aa8f9960..ebe4cbc7e 100644 --- a/events/exchange/exchange_test.go +++ b/events/exchange/exchange_test.go @@ -71,7 +71,7 @@ func TestExchangeBasic(t *testing.T) { cancel: cancel2, }, } { - var received []Event + var received []events.Event subscribercheck: for { select { diff --git a/linux/bundle.go b/linux/bundle.go index 1bad91270..72fcab9fe 100644 --- a/linux/bundle.go +++ b/linux/bundle.go @@ -72,11 +72,11 @@ type bundle struct { } // 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 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), 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 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) } } // ShimConnect is a ShimOpt for connecting to an existing remote shim 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)) } } diff --git a/linux/shim/client/client.go b/linux/shim/client/client.go index 367d7150e..1cfe766c2 100644 --- a/linux/shim/client/client.go +++ b/linux/shim/client/client.go @@ -31,11 +31,11 @@ import ( var empty = &google_protobuf.Empty{} -// ClientOpt is an option for a shim client configuration -type ClientOpt func(context.Context, shim.Config) (shimapi.ShimClient, io.Closer, error) +// Opt is an option for a shim client configuration +type Opt func(context.Context, shim.Config) (shimapi.ShimClient, io.Closer, error) // 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) { socket, err := newSocket(address) if err != nil { @@ -164,7 +164,7 @@ func dialAddress(address string) string { } // 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) { conn, err := connect(address, annonDialer) if err != nil { @@ -186,7 +186,7 @@ func WithLocal(publisher events.Publisher) func(context.Context, shim.Config) (s } // 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) if err != nil { return nil, err