driver: don't create tracer delegate opt if tracer is nil

The error handling for the cast to client.TracerDelegate was incorrect,
and previously, a client would unconditionally append an opt.

This results in the scenario that while the ClientOpt was not nil, the
tracer delegate in the ClientOpt was, which isn't an error case
explicitly handled by buildkit.

Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
Justin Chadwell 2022-10-31 11:19:47 +00:00
parent eab3f704f5
commit 7f008a7d1e
2 changed files with 14 additions and 8 deletions

View File

@ -366,11 +366,14 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
return nil, err return nil, err
} }
td, _ := exp.(client.TracerDelegate) var opts []client.ClientOpt
opts = append(opts, client.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return client.New(ctx, "", client.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return conn, nil return conn, nil
}), client.WithTracerDelegate(td)) }))
if td, ok := exp.(client.TracerDelegate); ok {
opts = append(opts, client.WithTracerDelegate(td))
}
return client.New(ctx, "", opts...)
} }
func (d *Driver) Factory() driver.Factory { func (d *Driver) Factory() driver.Factory {

View File

@ -215,11 +215,14 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
return nil, err return nil, err
} }
td, _ := exp.(client.TracerDelegate) var opts []client.ClientOpt
opts = append(opts, client.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return client.New(ctx, "", client.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return conn, nil return conn, nil
}), client.WithTracerDelegate(td)) }))
if td, ok := exp.(client.TracerDelegate); ok {
opts = append(opts, client.WithTracerDelegate(td))
}
return client.New(ctx, "", opts...)
} }
func (d *Driver) Factory() driver.Factory { func (d *Driver) Factory() driver.Factory {