本文整理匯總了Golang中github.com/juju/juju/jujuclient.ClientStore.CurrentModel方法的典型用法代碼示例。如果您正苦於以下問題:Golang ClientStore.CurrentModel方法的具體用法?Golang ClientStore.CurrentModel怎麽用?Golang ClientStore.CurrentModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/jujuclient.ClientStore
的用法示例。
在下文中一共展示了ClientStore.CurrentModel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: missingModelError
func (c *JujuCommandBase) missingModelError(store jujuclient.ClientStore, controllerName, modelName string) error {
// First, we'll try and clean up the missing model from the local cache.
err := store.RemoveModel(controllerName, modelName)
if err != nil {
logger.Warningf("cannot remove unknown model from cache: %v", err)
}
currentModel, err := store.CurrentModel(controllerName)
if err != nil {
logger.Warningf("cannot read current model: %v", err)
} else if currentModel == modelName {
if err := store.SetCurrentModel(controllerName, ""); err != nil {
logger.Warningf("cannot reset current model: %v", err)
}
}
errorMessage := "model %q has been removed from the controller, run 'juju models' and switch to one of them."
modelInfoMessage := "\nThere are %d accessible models on controller %q."
models, err := store.AllModels(controllerName)
if err == nil {
modelInfoMessage = fmt.Sprintf(modelInfoMessage, len(models), controllerName)
} else {
modelInfoMessage = ""
}
return errors.Errorf(errorMessage+modelInfoMessage, modelName)
}