-
Notifications
You must be signed in to change notification settings - Fork 229
/
client.go
57 lines (48 loc) · 1.34 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package client
import (
"os"
"path/filepath"
"github.com/containerd/containerd/snapshots/overlay"
"github.com/genuinetools/img/types"
"github.com/moby/buildkit/control"
"github.com/moby/buildkit/session"
"github.com/sirupsen/logrus"
)
// Client holds the information for the client we will use for communicating
// with the buildkit controller.
type Client struct {
backend string
localDirs map[string]string
root string
sessionManager *session.Manager
controller *control.Controller
}
// New returns a new client for communicating with the buildkit controller.
func New(root, backend string, localDirs map[string]string) (*Client, error) {
// Set the name for the directory executor.
name := "runc"
switch backend {
case types.AutoBackend:
if overlay.Supported(root) == nil {
backend = types.OverlayFSBackend
} else {
backend = types.NativeBackend
}
logrus.Debugf("using backend: %s", backend)
}
// Create the root/
root = filepath.Join(root, name, backend)
if err := os.MkdirAll(root, 0700); err != nil {
return nil, err
}
// Create the start of the client.
return &Client{
backend: backend,
root: root,
localDirs: localDirs,
}, nil
}
// Close safely closes the client.
// This used to shut down the FUSE server but since that was removed
// it is basically a no-op now.
func (c *Client) Close() {}