// VolumeParams returns the parameters for creating or destroying // the given volume. func VolumeParams( v state.Volume, storageInstance state.StorageInstance, modelUUID, controllerUUID string, environConfig *config.Config, poolManager poolmanager.PoolManager, registry storage.ProviderRegistry, ) (params.VolumeParams, error) { var pool string var size uint64 if stateVolumeParams, ok := v.Params(); ok { pool = stateVolumeParams.Pool size = stateVolumeParams.Size } else { volumeInfo, err := v.Info() if err != nil { return params.VolumeParams{}, errors.Trace(err) } pool = volumeInfo.Pool size = volumeInfo.Size } volumeTags, err := storageTags(storageInstance, modelUUID, controllerUUID, environConfig) if err != nil { return params.VolumeParams{}, errors.Annotate(err, "computing storage tags") } providerType, cfg, err := StoragePoolConfig(pool, poolManager, registry) if err != nil { return params.VolumeParams{}, errors.Trace(err) } return params.VolumeParams{ v.Tag().String(), size, string(providerType), cfg.Attrs(), volumeTags, nil, // attachment params set by the caller }, nil }