Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor: rename `s3` feature flag to `aws_s3` (#3341)

Chethan Rao1c04ac751240
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 8897fdac2c..88272033fb 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -10,12 +10,12 @@ license.workspace = true
[features]
default = ["kv_store", "stripe", "oltp", "olap", "backwards_compatibility", "accounts_cache", "dummy_connector", "payouts", "business_profile_routing", "connector_choice_mca_id", "profile_specific_fallback_routing", "retry", "frm"]
-s3 = ["dep:aws-sdk-s3", "dep:aws-config"]
+aws_s3 = ["dep:aws-sdk-s3", "dep:aws-config"]
kms = ["external_services/kms", "dep:aws-config"]
email = ["external_services/email", "dep:aws-config", "olap"]
frm = []
stripe = ["dep:serde_qs"]
-release = ["kms", "stripe", "s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon"]
+release = ["kms", "stripe", "aws_s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen", "recon"]
olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "dep:analytics"]
oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index bcf26d63ae..cb4fdd70eb 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -88,7 +88,7 @@ pub struct Settings {
pub api_keys: ApiKeys,
#[cfg(feature = "kms")]
pub kms: kms::KmsConfig,
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
pub file_upload_config: FileUploadConfig,
pub tokenization: TokenizationConfig,
pub connector_customer: ConnectorCustomer,
@@ -717,7 +717,7 @@ pub struct ApiKeys {
pub expiry_reminder_days: Vec<u8>,
}
-#[cfg(feature = "s3")]
+#[cfg(feature = "aws_s3")]
#[derive(Debug, Deserialize, Clone, Default)]
#[serde(default)]
pub struct FileUploadConfig {
@@ -849,7 +849,7 @@ impl Settings {
self.kms
.validate()
.map_err(|error| ApplicationError::InvalidConfigurationValueError(error.into()))?;
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
self.file_upload_config.validate()?;
self.lock_settings.validate()?;
self.events.validate()?;
diff --git a/crates/router/src/configs/validations.rs b/crates/router/src/configs/validations.rs
index 569262d0d2..0b286ece84 100644
--- a/crates/router/src/configs/validations.rs
+++ b/crates/router/src/configs/validations.rs
@@ -127,7 +127,7 @@ impl super::settings::DrainerSettings {
}
}
-#[cfg(feature = "s3")]
+#[cfg(feature = "aws_s3")]
impl super::settings::FileUploadConfig {
pub fn validate(&self) -> Result<(), ApplicationError> {
use common_utils::fp_utils::when;
diff --git a/crates/router/src/core/files.rs b/crates/router/src/core/files.rs
index 13c4d3dfdf..f3e5648980 100644
--- a/crates/router/src/core/files.rs
+++ b/crates/router/src/core/files.rs
@@ -1,8 +1,8 @@
pub mod helpers;
-#[cfg(feature = "s3")]
+#[cfg(feature = "aws_s3")]
pub mod s3_utils;
-#[cfg(not(feature = "s3"))]
+#[cfg(not(feature = "aws_s3"))]
pub mod fs_utils;
use api_models::files;
@@ -29,9 +29,9 @@ pub async fn files_create_core(
)
.await?;
let file_id = common_utils::generate_id(consts::ID_LENGTH, "file");
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
let file_key = format!("{}/{}", merchant_account.merchant_id, file_id);
- #[cfg(not(feature = "s3"))]
+ #[cfg(not(feature = "aws_s3"))]
let file_key = format!("{}_{}", merchant_account.merchant_id, file_id);
let file_new = diesel_models::file::FileMetadataNew {
file_id: file_id.clone(),
diff --git a/crates/router/src/core/files/helpers.rs b/crates/router/src/core/files/helpers.rs
index 818067207f..9205d42aee 100644
--- a/crates/router/src/core/files/helpers.rs
+++ b/crates/router/src/core/files/helpers.rs
@@ -31,33 +31,33 @@ pub async fn get_file_purpose(field: &mut Field) -> Option<api::FilePurpose> {
}
pub async fn upload_file(
- #[cfg(feature = "s3")] state: &AppState,
+ #[cfg(feature = "aws_s3")] state: &AppState,
file_key: String,
file: Vec<u8>,
) -> CustomResult<(), errors::ApiErrorResponse> {
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
return files::s3_utils::upload_file_to_s3(state, file_key, file).await;
- #[cfg(not(feature = "s3"))]
+ #[cfg(not(feature = "aws_s3"))]
return files::fs_utils::save_file_to_fs(file_key, file);
}
pub async fn delete_file(
- #[cfg(feature = "s3")] state: &AppState,
+ #[cfg(feature = "aws_s3")] state: &AppState,
file_key: String,
) -> CustomResult<(), errors::ApiErrorResponse> {
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
return files::s3_utils::delete_file_from_s3(state, file_key).await;
- #[cfg(not(feature = "s3"))]
+ #[cfg(not(feature = "aws_s3"))]
return files::fs_utils::delete_file_from_fs(file_key);
}
pub async fn retrieve_file(
- #[cfg(feature = "s3")] state: &AppState,
+ #[cfg(feature = "aws_s3")] state: &AppState,
file_key: String,
) -> CustomResult<Vec<u8>, errors::ApiErrorResponse> {
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
return files::s3_utils::retrieve_file_from_s3(state, file_key).await;
- #[cfg(not(feature = "s3"))]
+ #[cfg(not(feature = "aws_s3"))]
return files::fs_utils::retrieve_file_from_fs(file_key);
}
@@ -134,7 +134,7 @@ pub async fn delete_file_using_file_id(
match provider {
diesel_models::enums::FileUploadProvider::Router => {
delete_file(
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
state,
provider_file_id,
)
@@ -235,7 +235,7 @@ pub async fn retrieve_file_and_provider_file_id_from_file_id(
diesel_models::enums::FileUploadProvider::Router => Ok((
Some(
retrieve_file(
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
state,
provider_file_id.clone(),
)
@@ -365,7 +365,7 @@ pub async fn upload_and_get_provider_provider_file_id_profile_id(
))
} else {
upload_file(
- #[cfg(feature = "s3")]
+ #[cfg(feature = "aws_s3")]
state,
file_key.clone(),
create_file_request.file.clone(),