mirror of
https://github.com/moby/buildkit.git
synced 2026-08-06 07:40:49 +00:00
client: use grpc.DialContext and context.WithTimeout instead of grpc.WithTimeout
Currently, grpc.WithTimeout is deprecated.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io/ioutil"
|
||||
@@ -24,7 +25,6 @@ type ClientOpt interface{}
|
||||
// New returns a new buildkit client. Address can be empty for the system-default address.
|
||||
func New(address string, opts ...ClientOpt) (*Client, error) {
|
||||
gopts := []grpc.DialOption{
|
||||
grpc.WithTimeout(30 * time.Second),
|
||||
grpc.WithDialer(dialer),
|
||||
grpc.FailOnNonTempDialError(true),
|
||||
}
|
||||
@@ -53,7 +53,11 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
|
||||
if address == "" {
|
||||
address = appdefaults.Address
|
||||
}
|
||||
conn, err := grpc.Dial(address, gopts...)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
conn, err := grpc.DialContext(ctx, address, gopts...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to dial %q . make sure buildkitd is running", address)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user