Skip to content

Commit

Permalink
CDH/storage: reorganize aliyun plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Xynnn007 <[email protected]>
  • Loading branch information
Xynnn007 committed Apr 15, 2024
1 parent c99fe1f commit e1a207d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion confidential-data-hub/docs/SECURE_STORAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We reuse [direct block device assigned volume feature](https://github.com/kata-c

[Aliyun OSS](https://www.alibabacloud.com/product/object-storage-service) is an object storage service provided by Alibaba Cloud (Aliyun).

The [plugin](../storage/src/volume_type/alibaba_cloud_oss/) provides two different modes for secure mount.
The [plugin](../storage/src/volume_type/aliyun) provides two different modes for secure mount.

Confidential Data Hub's `secure_mount()` [API](../hub/protos/api.proto) will help to instrument this.

Expand Down
2 changes: 1 addition & 1 deletion confidential-data-hub/storage/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub type Result<T> = std::result::Result<T, Error>;
pub enum Error {
#[cfg(feature = "aliyun")]
#[error("Error when mounting Aliyun OSS")]
AliyunOssError(#[from] volume_type::alibaba_cloud_oss::error::Error),
AliyunOssError(#[from] volume_type::aliyun::error::AliyunError),

#[error("Failed to recognize the storage type")]
StorageTypeNotRecognized(#[from] strum::ParseError),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

use thiserror::Error;

pub type Result<T> = std::result::Result<T, Error>;
pub type Result<T> = std::result::Result<T, AliyunError>;

#[derive(Error, Debug)]
pub enum Error {
pub enum AliyunError {
#[error("Error when getting plaintext of OSS parameters")]
GetPlaintextParameter(#[from] anyhow::Error),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use secret::secret::Secret;
use serde::{Deserialize, Serialize};
use tokio::{fs, io::AsyncWriteExt, process::Command};

use error::{Error, Result};
use error::{AliyunError, Result};

use super::SecureMount;

Expand Down Expand Up @@ -154,11 +154,11 @@ impl Oss {
let mut oss = Command::new(OSSFS_BIN)
.args(parameters)
.spawn()
.map_err(|_| Error::OssfsMountFailed)?;
.map_err(|_| AliyunError::OssfsMountFailed)?;
let oss_res = oss.wait().await?;
if !oss_res.success() {
{
return Err(Error::OssfsMountFailed);
return Err(AliyunError::OssfsMountFailed);
}
}

Expand All @@ -185,12 +185,12 @@ impl Oss {
let mut gocryptfs = Command::new(GOCRYPTFS_BIN)
.args(parameters)
.spawn()
.map_err(|_| Error::GocryptfsMountFailed)?;
.map_err(|_| AliyunError::GocryptfsMountFailed)?;

let gocryptfs_res = gocryptfs.wait().await?;
if !gocryptfs_res.success() {
{
return Err(Error::GocryptfsMountFailed);
return Err(AliyunError::GocryptfsMountFailed);
}
}
} else {
Expand All @@ -205,11 +205,11 @@ impl Oss {
let mut oss = Command::new(OSSFS_BIN)
.args(parameters)
.spawn()
.map_err(|_| Error::OssfsMountFailed)?;
.map_err(|_| AliyunError::OssfsMountFailed)?;
let oss_res = oss.wait().await?;
if !oss_res.success() {
{
return Err(Error::OssfsMountFailed);
return Err(AliyunError::OssfsMountFailed);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions confidential-data-hub/storage/src/volume_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//

#[cfg(feature = "aliyun")]
pub mod alibaba_cloud_oss;
pub mod aliyun;

use std::{collections::HashMap, str::FromStr};

Expand Down Expand Up @@ -56,7 +56,7 @@ impl Storage {
match volume_type {
#[cfg(feature = "aliyun")]
Volume::AliOss => {
let oss = alibaba_cloud_oss::Oss {};
let oss = aliyun::Oss {};
oss.mount(&self.options, &self.flags, &self.mount_point)
.await?;
Ok(self.mount_point.clone())
Expand Down

0 comments on commit e1a207d

Please sign in to comment.