@@ -34,7 +34,9 @@ type Client struct {
34
34
sessionDialer func (ctx context.Context , proto string , meta map [string ][]string ) (net.Conn , error )
35
35
}
36
36
37
- type ClientOpt interface {}
37
+ type ClientOpt interface {
38
+ isClientOpt ()
39
+ }
38
40
39
41
// New returns a new buildkit client. Address can be empty for the system-default address.
40
42
func New (ctx context.Context , address string , opts ... ClientOpt ) (* Client , error ) {
@@ -82,8 +84,8 @@ func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error
82
84
if sd , ok := o .(* withSessionDialer ); ok {
83
85
sessionDialer = sd .dialer
84
86
}
85
- if opt , ok := o .(grpc. DialOption ); ok {
86
- customDialOptions = append (customDialOptions , opt )
87
+ if opt , ok := o .(* withGRPCDialOption ); ok {
88
+ customDialOptions = append (customDialOptions , opt . opt )
87
89
}
88
90
}
89
91
@@ -182,6 +184,8 @@ func (c *Client) Close() error {
182
184
183
185
type withFailFast struct {}
184
186
187
+ func (* withFailFast ) isClientOpt () {}
188
+
185
189
func WithFailFast () ClientOpt {
186
190
return & withFailFast {}
187
191
}
@@ -190,6 +194,8 @@ type withDialer struct {
190
194
dialer func (context.Context , string ) (net.Conn , error )
191
195
}
192
196
197
+ func (* withDialer ) isClientOpt () {}
198
+
193
199
func WithContextDialer (df func (context.Context , string ) (net.Conn , error )) ClientOpt {
194
200
return & withDialer {dialer : df }
195
201
}
@@ -201,6 +207,8 @@ type withCredentials struct {
201
207
Key string
202
208
}
203
209
210
+ func (* withCredentials ) isClientOpt () {}
211
+
204
212
// WithCredentials configures the TLS parameters of the client.
205
213
// Arguments:
206
214
// * serverName: specifies the name of the target server
@@ -247,6 +255,8 @@ type withTracer struct {
247
255
tp trace.TracerProvider
248
256
}
249
257
258
+ func (w * withTracer ) isClientOpt () {}
259
+
250
260
type TracerDelegate interface {
251
261
SetSpanExporter (context.Context , sdktrace.SpanExporter ) error
252
262
}
@@ -261,6 +271,8 @@ type withTracerDelegate struct {
261
271
TracerDelegate
262
272
}
263
273
274
+ func (w * withTracerDelegate ) isClientOpt () {}
275
+
264
276
func WithSessionDialer (dialer func (context.Context , string , map [string ][]string ) (net.Conn , error )) ClientOpt {
265
277
return & withSessionDialer {dialer }
266
278
}
@@ -269,6 +281,8 @@ type withSessionDialer struct {
269
281
dialer func (context.Context , string , map [string ][]string ) (net.Conn , error )
270
282
}
271
283
284
+ func (w * withSessionDialer ) isClientOpt () {}
285
+
272
286
func resolveDialer (address string ) (func (context.Context , string ) (net.Conn , error ), error ) {
273
287
ch , err := connhelper .GetConnectionHelper (address )
274
288
if err != nil {
@@ -289,3 +303,13 @@ func filterInterceptor(intercept grpc.UnaryClientInterceptor) grpc.UnaryClientIn
289
303
return intercept (ctx , method , req , reply , cc , invoker , opts ... )
290
304
}
291
305
}
306
+
307
+ type withGRPCDialOption struct {
308
+ opt grpc.DialOption
309
+ }
310
+
311
+ func (* withGRPCDialOption ) isClientOpt () {}
312
+
313
+ func WithGRPCDialOption (opt grpc.DialOption ) ClientOpt {
314
+ return & withGRPCDialOption {opt }
315
+ }
0 commit comments