2017-02-17 08:07:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"path/filepath"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/containerd/content"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func resolveContentStore(context *cli.Context) (*content.Store, error) {
|
2017-02-22 07:41:11 +00:00
|
|
|
root := filepath.Join(context.GlobalString("root"), "content")
|
2017-02-17 08:07:02 +00:00
|
|
|
if !filepath.IsAbs(root) {
|
|
|
|
var err error
|
|
|
|
root, err = filepath.Abs(root)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return content.NewStore(root)
|
|
|
|
}
|
|
|
|
|
|
|
|
func connectGRPC(context *cli.Context) (*grpc.ClientConn, error) {
|
|
|
|
socket := context.GlobalString("socket")
|
2017-03-01 00:43:08 +00:00
|
|
|
timeout := context.GlobalDuration("connect-timeout")
|
2017-02-17 08:07:02 +00:00
|
|
|
return grpc.Dial(socket,
|
2017-03-01 00:43:08 +00:00
|
|
|
grpc.WithTimeout(timeout),
|
2017-02-17 08:07:02 +00:00
|
|
|
grpc.WithBlock(),
|
|
|
|
grpc.WithInsecure(),
|
|
|
|
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
|
|
|
return net.DialTimeout("unix", socket, timeout)
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
}
|