-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory.go
31 lines (26 loc) · 924 Bytes
/
factory.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
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// This package exists solely to avoid circular imports.
package factory
import (
"github.com/juju/errors"
"github.com/juju/juju/container"
"github.com/juju/juju/container/kvm"
"github.com/juju/juju/container/lxd"
"github.com/juju/juju/core/instance"
)
// NewContainerManager creates the appropriate container.Manager for the
// specified container type.
var NewContainerManager = func(forType instance.ContainerType, conf container.ManagerConfig) (container.Manager, error) {
switch forType {
case instance.LXD:
svr, err := lxd.MaybeNewLocalServer()
if err != nil {
return nil, errors.Annotate(err, "creating LXD container manager")
}
return lxd.NewContainerManager(conf, svr)
case instance.KVM:
return kvm.NewContainerManager(conf)
}
return nil, errors.Errorf("unknown container type: %q", forType)
}