atlas_cli/storage/
mod.rs

1pub mod config;
2pub mod database;
3pub mod filesystem;
4pub mod rekor;
5pub mod traits;
6use crate::error::Result;
7pub use database::DatabaseStorage;
8pub use filesystem::FilesystemStorage;
9pub use rekor::RekorStorage;
10pub use traits::{ManifestMetadata, ManifestType, StorageBackend};
11
12pub fn initialize_storage() -> Result<RekorStorage> {
13    RekorStorage::new()
14}
15
16pub fn create_storage(storage_type: &str, url: String) -> Result<Box<dyn StorageBackend>> {
17    match storage_type {
18        "database" => Ok(Box::new(DatabaseStorage::new(url)?)),
19        "rekor" => Ok(Box::new(RekorStorage::new_with_url(url)?)),
20        "local-fs" => Ok(Box::new(FilesystemStorage::new(url)?)),
21        // Backwards compatibility with warnings
22        "local" => {
23            eprintln!(
24                "Warning: Storage type 'local' is deprecated and will be removed in a future version. Use 'database' instead."
25            );
26            Ok(Box::new(DatabaseStorage::new(url)?))
27        }
28        "filesystem" => {
29            eprintln!(
30                "Warning: Storage type 'filesystem' is deprecated and will be removed in a future version. Use 'local-fs' instead."
31            );
32            Ok(Box::new(FilesystemStorage::new(url)?))
33        }
34        _ => Err(crate::error::Error::Validation(
35            "Invalid storage type. Valid options are: database, rekor, local-fs".to_string(),
36        )),
37    }
38}