Skip to content

Refactor storage backend creation #77

@marcelamelara

Description

@marcelamelara

Current storage backend creation in the CLI leaks memory.

Maybe we can add small helper ? But this is separate issue, anyway.

fn create_storage_backend(storage_type: &str, storage_url: &str) -> Result<Box<dyn StorageBackend>> {
    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))),
    }
}
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 #55 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions