mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor: rename kms feature flag to aws_kms (#3249)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -13,14 +13,14 @@ pub mod recon;
|
||||
#[cfg(feature = "email")]
|
||||
pub mod email;
|
||||
|
||||
#[cfg(any(feature = "kms", feature = "hashicorp-vault"))]
|
||||
#[cfg(any(feature = "aws_kms", feature = "hashicorp-vault"))]
|
||||
use data_models::errors::StorageError;
|
||||
use data_models::errors::StorageResult;
|
||||
use error_stack::{IntoReport, ResultExt};
|
||||
#[cfg(feature = "aws_kms")]
|
||||
use external_services::aws_kms::{self, decrypt::AwsKmsDecrypt};
|
||||
#[cfg(feature = "hashicorp-vault")]
|
||||
use external_services::hashicorp_vault::decrypt::VaultFetch;
|
||||
#[cfg(feature = "kms")]
|
||||
use external_services::kms::{self, decrypt::KmsDecrypt};
|
||||
use masking::{PeekInterface, StrongSecret};
|
||||
#[cfg(feature = "kv_store")]
|
||||
use storage_impl::KVRouterStore;
|
||||
@ -45,8 +45,8 @@ pub async fn get_store(
|
||||
shut_down_signal: oneshot::Sender<()>,
|
||||
test_transaction: bool,
|
||||
) -> StorageResult<Store> {
|
||||
#[cfg(feature = "kms")]
|
||||
let kms_client = kms::get_kms_client(&config.kms).await;
|
||||
#[cfg(feature = "aws_kms")]
|
||||
let aws_kms_client = aws_kms::get_aws_kms_client(&config.kms).await;
|
||||
|
||||
#[cfg(feature = "hashicorp-vault")]
|
||||
let hc_client = external_services::hashicorp_vault::get_hashicorp_client(&config.hc_vault)
|
||||
@ -62,9 +62,9 @@ pub async fn get_store(
|
||||
.change_context(StorageError::InitializationError)
|
||||
.attach_printable("Failed to fetch data from hashicorp vault")?;
|
||||
|
||||
#[cfg(feature = "kms")]
|
||||
#[cfg(feature = "aws_kms")]
|
||||
let master_config = master_config
|
||||
.decrypt_inner(kms_client)
|
||||
.decrypt_inner(aws_kms_client)
|
||||
.await
|
||||
.change_context(StorageError::InitializationError)
|
||||
.attach_printable("Failed to decrypt master database config")?;
|
||||
@ -79,17 +79,17 @@ pub async fn get_store(
|
||||
.change_context(StorageError::InitializationError)
|
||||
.attach_printable("Failed to fetch data from hashicorp vault")?;
|
||||
|
||||
#[cfg(all(feature = "olap", feature = "kms"))]
|
||||
#[cfg(all(feature = "olap", feature = "aws_kms"))]
|
||||
let replica_config = replica_config
|
||||
.decrypt_inner(kms_client)
|
||||
.decrypt_inner(aws_kms_client)
|
||||
.await
|
||||
.change_context(StorageError::InitializationError)
|
||||
.attach_printable("Failed to decrypt replica database config")?;
|
||||
|
||||
let master_enc_key = get_master_enc_key(
|
||||
config,
|
||||
#[cfg(feature = "kms")]
|
||||
kms_client,
|
||||
#[cfg(feature = "aws_kms")]
|
||||
aws_kms_client,
|
||||
#[cfg(feature = "hashicorp-vault")]
|
||||
hc_client,
|
||||
)
|
||||
@ -128,7 +128,7 @@ pub async fn get_store(
|
||||
#[allow(clippy::expect_used)]
|
||||
async fn get_master_enc_key(
|
||||
conf: &crate::configs::settings::Settings,
|
||||
#[cfg(feature = "kms")] kms_client: &kms::KmsClient,
|
||||
#[cfg(feature = "aws_kms")] aws_kms_client: &aws_kms::AwsKmsClient,
|
||||
#[cfg(feature = "hashicorp-vault")]
|
||||
hc_client: &external_services::hashicorp_vault::HashiCorpVault,
|
||||
) -> StrongSecret<Vec<u8>> {
|
||||
@ -140,10 +140,10 @@ async fn get_master_enc_key(
|
||||
.await
|
||||
.expect("Failed to fetch master enc key");
|
||||
|
||||
#[cfg(feature = "kms")]
|
||||
#[cfg(feature = "aws_kms")]
|
||||
let master_enc_key = masking::Secret::<_, masking::WithType>::new(
|
||||
master_enc_key
|
||||
.decrypt_inner(kms_client)
|
||||
.decrypt_inner(aws_kms_client)
|
||||
.await
|
||||
.expect("Failed to decrypt master enc key"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user