Use v2 config.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-06-10 20:26:38 -07:00
parent efba8e147f
commit 150232325e
2 changed files with 20 additions and 11 deletions

View File

@@ -18,6 +18,8 @@ package client
import (
"context"
"net"
"time"
"github.com/pkg/errors"
"google.golang.org/grpc"
@@ -36,7 +38,13 @@ func NewCRIPluginClient(ctx context.Context, endpoint string) (api.CRIPluginServ
conn, err := grpc.DialContext(ctx, addr,
grpc.WithBlock(),
grpc.WithInsecure(),
grpc.WithDialer(dialer),
grpc.WithContextDialer(
func(ctx context.Context, addr string) (net.Conn, error) {
if deadline, ok := ctx.Deadline(); ok {
return dialer(addr, time.Until(deadline))
}
return dialer(addr, 0)
}),
)
if err != nil {
return nil, errors.Wrap(err, "failed to dial")