client: allow empty address for the system-default value
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>docker-18.09
parent
70521789fe
commit
c5ba23d886
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
controlapi "github.com/moby/buildkit/api/services/control"
|
||||
"github.com/moby/buildkit/util/appdefaults"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -14,7 +15,7 @@ type Client struct {
|
|||
|
||||
type ClientOpt interface{}
|
||||
|
||||
// New returns a new buildkit client
|
||||
// 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.WithInsecure(),
|
||||
|
@ -27,6 +28,9 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
|
|||
gopts = append(gopts, grpc.WithBlock(), grpc.FailOnNonTempDialError(true))
|
||||
}
|
||||
}
|
||||
if address == "" {
|
||||
address = appdefaults.Socket
|
||||
}
|
||||
conn, err := grpc.Dial(dialAddress(address), gopts...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to dial %q . make sure buildd is running", address)
|
||||
|
|
Loading…
Reference in New Issue