github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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/instance" 15 "github.com/juju/juju/storage/looputil" 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, 21 ) (container.Manager, error) { 22 switch forType { 23 case instance.LXC: 24 return lxc.NewContainerManager(conf, imageURLGetter, looputil.NewLoopDeviceManager()) 25 case instance.KVM: 26 return kvm.NewContainerManager(conf) 27 } 28 return nil, errors.Errorf("unknown container type: %q", forType) 29 }