github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/container/factory/factory.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 // This package exists solely to avoid circular imports. 5 6 package factory 7 8 import ( 9 "github.com/juju/errors" 10 11 "github.com/juju/juju/container" 12 "github.com/juju/juju/container/kvm" 13 "github.com/juju/juju/container/lxc" 14 "github.com/juju/juju/container/lxd" 15 "github.com/juju/juju/instance" 16 ) 17 18 // NewContainerManager creates the appropriate container.Manager for the 19 // specified container type. 20 func NewContainerManager(forType instance.ContainerType, conf container.ManagerConfig, imageURLGetter container.ImageURLGetter) (container.Manager, error) { 21 switch forType { 22 case instance.LXC: 23 return lxc.NewContainerManager(conf, imageURLGetter) 24 case instance.LXD: 25 return lxd.NewContainerManager(conf) 26 case instance.KVM: 27 return kvm.NewContainerManager(conf) 28 } 29 return nil, errors.Errorf("unknown container type: %q", forType) 30 }