func destroyVolumes( environConfig *config.Config, storageProviderType storage.ProviderType, storageProvider storage.Provider, ) error { if !storageProvider.Supports(storage.StorageKindBlock) { return nil } storageConfig, err := storage.NewConfig( string(storageProviderType), storageProviderType, map[string]interface{}{}, ) if err != nil { return errors.Trace(err) } volumeSource, err := storageProvider.VolumeSource(environConfig, storageConfig) if err != nil { return errors.Annotate(err, "getting volume source") } volumeIds, err := volumeSource.ListVolumes() if err != nil { return errors.Annotate(err, "listing volumes") } var errStrings []string errs, err := volumeSource.DestroyVolumes(volumeIds) if err != nil { return errors.Annotate(err, "destroying volumes") } for _, err := range errs { if err != nil { errStrings = append(errStrings, err.Error()) } } if len(errStrings) > 0 { return errors.Errorf("destroying volumes: %s", strings.Join(errStrings, ", ")) } return nil }
// 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) }
// ValidateConfig performs storage provider config validation, including // any common validation. func ValidateConfig(p storage.Provider, cfg *storage.Config) error { return p.ValidateConfig(cfg) }