@@ -11,7 +11,6 @@ import (
11
11
12
12
contentapi "github.com/containerd/containerd/api/services/content/v1"
13
13
"github.com/containerd/containerd/defaults"
14
- grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
15
14
controlapi "github.com/moby/buildkit/api/services/control"
16
15
"github.com/moby/buildkit/client/connhelper"
17
16
"github.com/moby/buildkit/session"
@@ -54,6 +53,7 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
54
53
var tracerProvider trace.TracerProvider
55
54
var tracerDelegate TracerDelegate
56
55
var sessionDialer func (context.Context , string , map [string ][]string ) (net.Conn , error )
56
+ var customDialOptions []grpc.DialOption
57
57
58
58
for _ , o := range opts {
59
59
if _ , ok := o .(* withFailFast ); ok {
@@ -82,6 +82,9 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
82
82
if sd , ok := o .(* withSessionDialer ); ok {
83
83
sessionDialer = sd .dialer
84
84
}
85
+ if opt , ok := o .(grpc.DialOption ); ok {
86
+ customDialOptions = append (customDialOptions , opt )
87
+ }
85
88
}
86
89
87
90
if ! customTracer {
@@ -131,17 +134,9 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
131
134
unary = append (unary , grpcerrors .UnaryClientInterceptor )
132
135
stream = append (stream , grpcerrors .StreamClientInterceptor )
133
136
134
- if len (unary ) == 1 {
135
- gopts = append (gopts , grpc .WithUnaryInterceptor (unary [0 ]))
136
- } else if len (unary ) > 1 {
137
- gopts = append (gopts , grpc .WithUnaryInterceptor (grpc_middleware .ChainUnaryClient (unary ... )))
138
- }
139
-
140
- if len (stream ) == 1 {
141
- gopts = append (gopts , grpc .WithStreamInterceptor (stream [0 ]))
142
- } else if len (stream ) > 1 {
143
- gopts = append (gopts , grpc .WithStreamInterceptor (grpc_middleware .ChainStreamClient (stream ... )))
144
- }
137
+ gopts = append (gopts , grpc .WithChainUnaryInterceptor (unary ... ))
138
+ gopts = append (gopts , grpc .WithChainStreamInterceptor (stream ... ))
139
+ gopts = append (gopts , customDialOptions ... )
145
140
146
141
conn , err := grpc .DialContext (ctx , address , gopts ... )
147
142
if err != nil {
0 commit comments