Skip to content

Commit

Permalink
added check in kv enable api
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay S authored and Akshay S committed May 14, 2024
1 parent e1bf5ff commit 2dbbd3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/router/src/configs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use external_services::{
},
};
use hyperswitch_interfaces::secrets_interface::secret_state::{
SecretState, SecretStateContainer, SecuredSecret,
SecretState, SecretStateContainer, SecuredSecret, RawSecret
};
use masking::Secret;
use redis_interface::RedisSettings;
Expand Down Expand Up @@ -760,6 +760,17 @@ impl Settings<SecuredSecret> {
}
}


impl Settings<RawSecret>{
pub fn is_kv_soft_kill_mode(&self) -> bool {
if cfg!(feature="kv_store") {
self.kv_config.soft_kill.unwrap_or(false)
} else {
false
}
}
}

#[cfg(feature = "payouts")]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct Payouts {
Expand Down
6 changes: 6 additions & 0 deletions crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,12 @@ pub async fn kv_for_merchant(
Ok(merchant_account)
}
(true, MerchantStorageScheme::PostgresOnly) => {
if state.conf.as_ref().is_kv_soft_kill_mode(){
Err(errors::ApiErrorResponse::InvalidRequestData {
message : "Kv cannot be enabled when application is in soft_kill_mode".to_owned()
})?
}

db.update_merchant(
merchant_account,
storage::MerchantAccountUpdate::StorageSchemeUpdate {
Expand Down

0 comments on commit 2dbbd3d

Please sign in to comment.