mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 13:38:26 +00:00
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:
parent
37bd2406e0
commit
1528d543b2
@ -10,13 +10,14 @@
|
||||
use anyhow::Result;
|
||||
use derivative::Derivative;
|
||||
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;
|
||||
|
||||
// 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.";
|
||||
|
||||
#[derive(Derivative)]
|
||||
@ -30,20 +31,19 @@ impl CDHClient {
|
||||
pub fn new() -> Result<Self> {
|
||||
let client = ttrpc::asynchronous::Client::connect(CDH_SOCKET_URI)?;
|
||||
let sealed_secret_client =
|
||||
sealed_secret_ttrpc_async::SealedSecretServiceClient::new(client);
|
||||
|
||||
confidential_data_hub_ttrpc_async::SealedSecretServiceClient::new(client);
|
||||
Ok(CDHClient {
|
||||
sealed_secret_client,
|
||||
})
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
let unsealed_secret = self
|
||||
.sealed_secret_client
|
||||
.unseal_secret(ttrpc::context::with_timeout(CDH_UNSEAL_TIMEOUT), &input)
|
||||
.unseal_secret(ttrpc::context::with_timeout(CDH_API_TIMEOUT), &input)
|
||||
.await?;
|
||||
Ok(unsealed_secret.plaintext)
|
||||
}
|
||||
@ -69,7 +69,7 @@ mod tests {
|
||||
use crate::cdh::CDH_ADDR;
|
||||
use anyhow::anyhow;
|
||||
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 test_utils::skip_if_not_root;
|
||||
use tokio::signal::unix::{signal, SignalKind};
|
||||
@ -77,13 +77,13 @@ mod tests {
|
||||
struct TestService;
|
||||
|
||||
#[async_trait]
|
||||
impl sealed_secret_ttrpc_async::SealedSecretService for TestService {
|
||||
impl confidential_data_hub_ttrpc_async::SealedSecretService for TestService {
|
||||
async fn unseal_secret(
|
||||
&self,
|
||||
_ctx: &::ttrpc::asynchronous::TtrpcContext,
|
||||
_req: sealed_secret::UnsealSecretInput,
|
||||
) -> ttrpc::error::Result<sealed_secret::UnsealSecretOutput> {
|
||||
let mut output = sealed_secret::UnsealSecretOutput::new();
|
||||
_req: confidential_data_hub::UnsealSecretInput,
|
||||
) -> ttrpc::error::Result<confidential_data_hub::UnsealSecretOutput> {
|
||||
let mut output = confidential_data_hub::UnsealSecretOutput::new();
|
||||
output.set_plaintext("unsealed".into());
|
||||
Ok(output)
|
||||
}
|
||||
@ -104,9 +104,9 @@ mod tests {
|
||||
fn start_ttrpc_server() {
|
||||
tokio::spawn(async move {
|
||||
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_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();
|
||||
|
||||
|
@ -203,7 +203,7 @@ fn real_main() -> Result<(), std::io::Error> {
|
||||
&[
|
||||
"protos/agent.proto",
|
||||
"protos/health.proto",
|
||||
"protos/sealed_secret.proto",
|
||||
"protos/confidential_data_hub.proto",
|
||||
],
|
||||
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/health_ttrpc.rs", "src/health_ttrpc_async.rs")?;
|
||||
fs::rename(
|
||||
"src/sealed_secret_ttrpc.rs",
|
||||
"src/sealed_secret_ttrpc_async.rs",
|
||||
"src/confidential_data_hub_ttrpc.rs",
|
||||
"src/confidential_data_hub_ttrpc_async.rs",
|
||||
)?;
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ fn real_main() -> Result<(), std::io::Error> {
|
||||
&[
|
||||
"protos/agent.proto",
|
||||
"protos/health.proto",
|
||||
"protos/sealed_secret.proto",
|
||||
"protos/confidential_data_hub.proto",
|
||||
],
|
||||
false,
|
||||
)?;
|
||||
|
@ -1,5 +1,6 @@
|
||||
//
|
||||
// Copyright (c) 2024 IBM
|
||||
// Copyright (c) 2024 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
@ -28,8 +28,8 @@ pub use serde_config::{
|
||||
serialize_message_field,
|
||||
};
|
||||
|
||||
pub mod sealed_secret;
|
||||
pub mod sealed_secret_ttrpc;
|
||||
pub mod confidential_data_hub;
|
||||
pub mod confidential_data_hub_ttrpc;
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
pub mod sealed_secret_ttrpc_async;
|
||||
pub mod confidential_data_hub_ttrpc_async;
|
||||
|
Loading…
Reference in New Issue
Block a user