agent:cdh: Rename sealed_secret API namespace to confidential_data_hub

renames the sealed_secret.proto file to confidential_data_hub.proto and
updates the corresponding API namespace from sealed_secret to confidential_data_hub.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
This commit is contained in:
ChengyuZhu6 2024-07-22 09:24:20 +08:00
parent 37bd2406e0
commit 1528d543b2
4 changed files with 21 additions and 20 deletions

View File

@ -10,13 +10,14 @@
use anyhow::Result; use anyhow::Result;
use derivative::Derivative; use derivative::Derivative;
use protocols::{ use protocols::{
sealed_secret, sealed_secret_ttrpc_async, sealed_secret_ttrpc_async::SealedSecretServiceClient, confidential_data_hub, confidential_data_hub_ttrpc_async,
confidential_data_hub_ttrpc_async::SealedSecretServiceClient,
}; };
use crate::CDH_SOCKET_URI; use crate::CDH_SOCKET_URI;
// Nanoseconds // Nanoseconds
const CDH_UNSEAL_TIMEOUT: i64 = 50 * 1000 * 1000 * 1000; const CDH_API_TIMEOUT: i64 = 50 * 1000 * 1000 * 1000;
const SEALED_SECRET_PREFIX: &str = "sealed."; const SEALED_SECRET_PREFIX: &str = "sealed.";
#[derive(Derivative)] #[derive(Derivative)]
@ -30,20 +31,19 @@ impl CDHClient {
pub fn new() -> Result<Self> { pub fn new() -> Result<Self> {
let client = ttrpc::asynchronous::Client::connect(CDH_SOCKET_URI)?; let client = ttrpc::asynchronous::Client::connect(CDH_SOCKET_URI)?;
let sealed_secret_client = let sealed_secret_client =
sealed_secret_ttrpc_async::SealedSecretServiceClient::new(client); confidential_data_hub_ttrpc_async::SealedSecretServiceClient::new(client);
Ok(CDHClient { Ok(CDHClient {
sealed_secret_client, sealed_secret_client,
}) })
} }
pub async fn unseal_secret_async(&self, sealed_secret: &str) -> Result<Vec<u8>> { pub async fn unseal_secret_async(&self, sealed_secret: &str) -> Result<Vec<u8>> {
let mut input = sealed_secret::UnsealSecretInput::new(); let mut input = confidential_data_hub::UnsealSecretInput::new();
input.set_secret(sealed_secret.into()); input.set_secret(sealed_secret.into());
let unsealed_secret = self let unsealed_secret = self
.sealed_secret_client .sealed_secret_client
.unseal_secret(ttrpc::context::with_timeout(CDH_UNSEAL_TIMEOUT), &input) .unseal_secret(ttrpc::context::with_timeout(CDH_API_TIMEOUT), &input)
.await?; .await?;
Ok(unsealed_secret.plaintext) Ok(unsealed_secret.plaintext)
} }
@ -69,7 +69,7 @@ mod tests {
use crate::cdh::CDH_ADDR; use crate::cdh::CDH_ADDR;
use anyhow::anyhow; use anyhow::anyhow;
use async_trait::async_trait; use async_trait::async_trait;
use protocols::{sealed_secret, sealed_secret_ttrpc_async}; use protocols::{confidential_data_hub, confidential_data_hub_ttrpc_async};
use std::sync::Arc; use std::sync::Arc;
use test_utils::skip_if_not_root; use test_utils::skip_if_not_root;
use tokio::signal::unix::{signal, SignalKind}; use tokio::signal::unix::{signal, SignalKind};
@ -77,13 +77,13 @@ mod tests {
struct TestService; struct TestService;
#[async_trait] #[async_trait]
impl sealed_secret_ttrpc_async::SealedSecretService for TestService { impl confidential_data_hub_ttrpc_async::SealedSecretService for TestService {
async fn unseal_secret( async fn unseal_secret(
&self, &self,
_ctx: &::ttrpc::asynchronous::TtrpcContext, _ctx: &::ttrpc::asynchronous::TtrpcContext,
_req: sealed_secret::UnsealSecretInput, _req: confidential_data_hub::UnsealSecretInput,
) -> ttrpc::error::Result<sealed_secret::UnsealSecretOutput> { ) -> ttrpc::error::Result<confidential_data_hub::UnsealSecretOutput> {
let mut output = sealed_secret::UnsealSecretOutput::new(); let mut output = confidential_data_hub::UnsealSecretOutput::new();
output.set_plaintext("unsealed".into()); output.set_plaintext("unsealed".into());
Ok(output) Ok(output)
} }
@ -104,9 +104,9 @@ mod tests {
fn start_ttrpc_server() { fn start_ttrpc_server() {
tokio::spawn(async move { tokio::spawn(async move {
let ss = Box::new(TestService {}) let ss = Box::new(TestService {})
as Box<dyn sealed_secret_ttrpc_async::SealedSecretService + Send + Sync>; as Box<dyn confidential_data_hub_ttrpc_async::SealedSecretService + Send + Sync>;
let ss = Arc::new(ss); let ss = Arc::new(ss);
let ss_service = sealed_secret_ttrpc_async::create_sealed_secret_service(ss); let ss_service = confidential_data_hub_ttrpc_async::create_sealed_secret_service(ss);
remove_if_sock_exist(CDH_ADDR).unwrap(); remove_if_sock_exist(CDH_ADDR).unwrap();

View File

@ -203,7 +203,7 @@ fn real_main() -> Result<(), std::io::Error> {
&[ &[
"protos/agent.proto", "protos/agent.proto",
"protos/health.proto", "protos/health.proto",
"protos/sealed_secret.proto", "protos/confidential_data_hub.proto",
], ],
true, true,
)?; )?;
@ -211,8 +211,8 @@ fn real_main() -> Result<(), std::io::Error> {
fs::rename("src/agent_ttrpc.rs", "src/agent_ttrpc_async.rs")?; fs::rename("src/agent_ttrpc.rs", "src/agent_ttrpc_async.rs")?;
fs::rename("src/health_ttrpc.rs", "src/health_ttrpc_async.rs")?; fs::rename("src/health_ttrpc.rs", "src/health_ttrpc_async.rs")?;
fs::rename( fs::rename(
"src/sealed_secret_ttrpc.rs", "src/confidential_data_hub_ttrpc.rs",
"src/sealed_secret_ttrpc_async.rs", "src/confidential_data_hub_ttrpc_async.rs",
)?; )?;
} }
@ -221,7 +221,7 @@ fn real_main() -> Result<(), std::io::Error> {
&[ &[
"protos/agent.proto", "protos/agent.proto",
"protos/health.proto", "protos/health.proto",
"protos/sealed_secret.proto", "protos/confidential_data_hub.proto",
], ],
false, false,
)?; )?;

View File

@ -1,5 +1,6 @@
// //
// Copyright (c) 2024 IBM // Copyright (c) 2024 IBM
// Copyright (c) 2024 Intel Corporation
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //

View File

@ -28,8 +28,8 @@ pub use serde_config::{
serialize_message_field, serialize_message_field,
}; };
pub mod sealed_secret; pub mod confidential_data_hub;
pub mod sealed_secret_ttrpc; pub mod confidential_data_hub_ttrpc;
#[cfg(feature = "async")] #[cfg(feature = "async")]
pub mod sealed_secret_ttrpc_async; pub mod confidential_data_hub_ttrpc_async;