Example #1
0
func addDefaultPool(pm PoolManager, pool *storage.Config) error {
	_, err := pm.Get(pool.Name())
	if err != nil && !errors.IsNotFound(err) {
		return errors.Annotatef(err, "loading default pool %q", pool.Name())
	}
	if err != nil {
		// We got a not found error, so default pool doesn't exist.
		if _, err := pm.Create(pool.Name(), pool.Provider(), pool.Attrs()); err != nil {
			return errors.Annotatef(err, "creating default pool %q", pool.Name())
		}
	}
	return nil
}
Example #2
0
// ValidateConfig performs storage provider config validation, including
// any common validation.
func ValidateConfig(p storage.Provider, cfg *storage.Config) error {
	if p.Scope() == storage.ScopeMachine && cfg.IsPersistent() {
		return errors.Errorf("machine scoped storage provider %q does not support persistent storage", cfg.Name())
	}
	return p.ValidateConfig(cfg)
}