github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/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  	"fmt"
    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) (container.Manager, error) {
    20  	switch forType {
    21  	case instance.LXC:
    22  		return lxc.NewContainerManager(conf)
    23  	case instance.KVM:
    24  		return kvm.NewContainerManager(conf)
    25  	}
    26  	return nil, fmt.Errorf("unknown container type: %q", forType)
    27  }