github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/storage/plans/plans.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package plans
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  
     9  	"github.com/juju/juju/storage"
    10  	"github.com/juju/juju/storage/plans/common"
    11  	"github.com/juju/juju/storage/plans/iscsi"
    12  	"github.com/juju/juju/storage/plans/local"
    13  )
    14  
    15  var registry = map[storage.DeviceType]common.Plan{
    16  	storage.DeviceTypeLocal: local.NewLocalPlan(),
    17  	storage.DeviceTypeISCSI: iscsi.NewiSCSIPlan(),
    18  }
    19  
    20  func PlanByType(name storage.DeviceType) (common.Plan, error) {
    21  	plan, ok := registry[name]
    22  	if !ok {
    23  		return nil, errors.NotFoundf("plan type %s not found", name)
    24  	}
    25  	return plan, nil
    26  }