MCPcopy Index your code
hub / github.com/genuinetools/img / createController

Method createController

client/controller.go:22–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20)
21
22func (c *Client) createController() error {
23 sm, err := c.getSessionManager()
24 if err != nil {
25 return fmt.Errorf("creating session manager failed: %v", err)
26 }
27 // Create the worker opts.
28 opt, err := c.createWorkerOpt(true)
29 if err != nil {
30 return fmt.Errorf("creating worker opt failed: %v", err)
31 }
32
33 // Create the new worker.
34 w, err := base.NewWorker(opt)
35 if err != nil {
36 return fmt.Errorf("creating worker failed: %v", err)
37 }
38
39 // Create the worker controller.
40 wc := &worker.Controller{}
41 if err := wc.Add(w); err != nil {
42 return fmt.Errorf("adding worker to worker controller failed: %v", err)
43 }
44
45 // Add the frontends.
46 frontends := map[string]frontend.Frontend{}
47 frontends["dockerfile.v0"] = forwarder.NewGatewayForwarder(wc, builder.Build)
48 frontends["gateway.v0"] = gateway.NewGatewayFrontend(wc)
49
50 // Create the cache storage
51 cacheStorage, err := bboltcachestorage.NewStore(filepath.Join(c.root, "cache.db"))
52 if err != nil {
53 return err
54 }
55
56 remoteCacheExporterFuncs := map[string]remotecache.ResolveCacheExporterFunc{
57 "inline": inlineremotecache.ResolveCacheExporterFunc(),
58 "local": localremotecache.ResolveCacheExporterFunc(sm),
59 "registry": registryremotecache.ResolveCacheExporterFunc(sm, docker.ConfigureDefaultRegistries()),
60 }
61 remoteCacheImporterFuncs := map[string]remotecache.ResolveCacheImporterFunc{
62 "local": localremotecache.ResolveCacheImporterFunc(sm),
63 "registry": registryremotecache.ResolveCacheImporterFunc(sm, opt.ContentStore, docker.ConfigureDefaultRegistries()),
64 }
65
66 // Create the controller.
67 controller, err := control.NewController(control.Opt{
68 SessionManager: sm,
69 WorkerController: wc,
70 Frontends: frontends,
71 ResolveCacheExporterFuncs: remoteCacheExporterFuncs,
72 ResolveCacheImporterFuncs: remoteCacheImporterFuncs,
73 CacheKeyStorage: cacheStorage,
74 })
75 if err != nil {
76 return fmt.Errorf("creating new controller failed: %v", err)
77 }
78
79 // Set the controller for the client.

Callers 2

SolveMethod · 0.95
DiskUsageMethod · 0.95

Calls 2

getSessionManagerMethod · 0.95
createWorkerOptMethod · 0.95

Tested by

no test coverage detected