Exemple #1
0
// UpdateModel implements ModelUpdater.
func (c *MemStore) UpdateModel(controller, account, model string, details jujuclient.ModelDetails) error {
	if err := jujuclient.ValidateControllerName(controller); err != nil {
		return err
	}
	if err := jujuclient.ValidateAccountName(account); err != nil {
		return err
	}
	if err := jujuclient.ValidateModelName(model); err != nil {
		return err
	}
	if err := jujuclient.ValidateModelDetails(details); err != nil {
		return err
	}
	controllerAccountModels, ok := c.Models[controller]
	if !ok {
		controllerAccountModels.AccountModels = make(map[string]*jujuclient.AccountModels)
		c.Models[controller] = controllerAccountModels
	}
	accountModels, ok := controllerAccountModels.AccountModels[account]
	if !ok {
		accountModels = &jujuclient.AccountModels{
			Models: make(map[string]jujuclient.ModelDetails),
		}
		controllerAccountModels.AccountModels[account] = accountModels
	}
	accountModels.Models[model] = details
	return nil
}
Exemple #2
0
func (s *ModelValidationSuite) assertValidateModelDetailsFails(c *gc.C, failureMessage string) {
	err := jujuclient.ValidateModelDetails(s.model)
	c.Assert(err, gc.ErrorMatches, failureMessage)
}