github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/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  )
    16  
    17  // NewContainerManager creates the appropriate container.Manager for the
    18  // specified container type.
    19  func NewContainerManager(forType instance.ContainerType, conf container.ManagerConfig, imageURLGetter container.ImageURLGetter,
    20  ) (container.Manager, error) {
    21  	switch forType {
    22  	case instance.LXC:
    23  		return lxc.NewContainerManager(conf, imageURLGetter)
    24  	case instance.KVM:
    25  		return kvm.NewContainerManager(conf)
    26  	}
    27  	return nil, errors.Errorf("unknown container type: %q", forType)
    28  }