IntelLabs / IntelLabs/atlas-cli
Refactor storage backend creation
- Dominant language
- Rust
- Stars
- 22
- Forks
- 4
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
Current storage backend creation in the CLI leaks memory.
Maybe we can add small helper ? But this is separate issue, anyway.
```rust
fn create_storage_backend(storage_type: &str, storage_url: &str) -> Result> {
match storage_type {
"local-fs" => Ok(Box::new(FilesystemStorage::new(storage_url)?)),
"database" => Ok(Box::new(DatabaseStorage::new(storage_url.to_string())?)),
"rekor" => Ok(Box::new(RekorStorage::new_with_url(storage_url.to_string())?)),
_ => Err(Error::Validation(format!("Unsupported storage type: {}", storage_type))),
}
}
```
```rust
let storage = if print { None } else { Some(create_storage_backend(storage_type.as_str(), storage_url.as_str())?) };
```
or something similar
_Originally posted by @sandlbn in https://github.com/IntelLabs/atlas-cli/pull/55#discussion_r2363390672_
Contributor guide
Assessment
This issue has not been assessed yet.