Merge pull request #139 from rustfs/fix/make-cargo-happy-1

refactor: make cargo check happy
This commit is contained in:
weisd
2024-12-03 10:38:01 +08:00
committed by GitHub
3 changed files with 11 additions and 10 deletions
+9 -9
View File
@@ -22,7 +22,7 @@ impl Operation for AddServiceAccount {
warn!("handle AddServiceAccount, req: {req:?}"); warn!("handle AddServiceAccount, req: {req:?}");
let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) };
let is_owner = true; // 先按true处理,后期根据请求决定。 let _is_owner = true; // 先按true处理,后期根据请求决定。
let body = req.input.store_all_unlimited().await.unwrap(); let body = req.input.store_all_unlimited().await.unwrap();
let body = crypto::decrypt_data(cred.secret_key.expose().as_bytes(), &body[..]) let body = crypto::decrypt_data(cred.secret_key.expose().as_bytes(), &body[..])
.map_err(|_| s3_error!(InternalError, "encrypt data failed"))?; .map_err(|_| s3_error!(InternalError, "encrypt data failed"))?;
@@ -39,8 +39,8 @@ impl Operation for AddServiceAccount {
} }
// 校验合法性, Name, Expiration, Description // 校验合法性, Name, Expiration, Description
let target_user = create_req.target_user.as_ref().unwrap_or(&cred.access_key); let _target_user = create_req.target_user.as_ref().unwrap_or(&cred.access_key);
let deny_only = true; let _deny_only = true;
// todo 校验权限 // todo 校验权限
@@ -109,7 +109,7 @@ impl Operation for UpdateServiceAccount {
async fn call(&self, req: S3Request<Body>, _params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> { async fn call(&self, req: S3Request<Body>, _params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> {
warn!("handle UpdateServiceAccount"); warn!("handle UpdateServiceAccount");
let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; let Some(_cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) };
// return Err(s3_error!(NotImplemented)); // return Err(s3_error!(NotImplemented));
// //
@@ -121,7 +121,7 @@ impl Operation for UpdateServiceAccount {
pub struct InfoServiceAccount {} pub struct InfoServiceAccount {}
#[async_trait::async_trait] #[async_trait::async_trait]
impl Operation for InfoServiceAccount { impl Operation for InfoServiceAccount {
async fn call(&self, req: S3Request<Body>, params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> { async fn call(&self, req: S3Request<Body>, _params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> {
warn!("handle InfoServiceAccount"); warn!("handle InfoServiceAccount");
let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) };
@@ -149,7 +149,7 @@ impl Operation for InfoServiceAccount {
return Err(s3_error!(InvalidRequest, "access key is not exist")); return Err(s3_error!(InvalidRequest, "access key is not exist"));
}; };
let (sa, sp) = iam::get_service_account(ak).await.map_err(|e| { let (sa, _sp) = iam::get_service_account(ak).await.map_err(|e| {
debug!("get service account failed, err: {e:?}"); debug!("get service account failed, err: {e:?}");
s3_error!(InternalError) s3_error!(InternalError)
})?; })?;
@@ -206,7 +206,7 @@ impl Operation for InfoServiceAccount {
pub struct ListServiceAccount {} pub struct ListServiceAccount {}
#[async_trait::async_trait] #[async_trait::async_trait]
impl Operation for ListServiceAccount { impl Operation for ListServiceAccount {
async fn call(&self, req: S3Request<Body>, params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> { async fn call(&self, _req: S3Request<Body>, _params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> {
warn!("handle ListServiceAccount"); warn!("handle ListServiceAccount");
todo!() todo!()
} }
@@ -218,9 +218,9 @@ impl Operation for DeleteServiceAccount {
async fn call(&self, req: S3Request<Body>, params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> { async fn call(&self, req: S3Request<Body>, params: Params<'_, '_>) -> S3Result<S3Response<(StatusCode, Body)>> {
warn!("handle DeleteServiceAccount"); warn!("handle DeleteServiceAccount");
let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; let Some(_cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) };
let Some(service_account) = params.get("accessKey") else { let Some(_service_account) = params.get("accessKey") else {
return Err(s3_error!(InvalidRequest, "Invalid arguments specified.")); return Err(s3_error!(InvalidRequest, "Invalid arguments specified."));
}; };
+1 -1
View File
@@ -26,7 +26,7 @@ use iam::init_iam_sys;
use protos::proto_gen::node_service::node_service_server::NodeServiceServer; use protos::proto_gen::node_service::node_service_server::NodeServiceServer;
use s3s::{auth::SimpleAuth, service::S3ServiceBuilder}; use s3s::{auth::SimpleAuth, service::S3ServiceBuilder};
use service::hybrid; use service::hybrid;
use std::{io::IsTerminal, net::SocketAddr, str::FromStr, sync::Arc}; use std::{io::IsTerminal, net::SocketAddr, str::FromStr};
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tonic::{metadata::MetadataValue, Request, Status}; use tonic::{metadata::MetadataValue, Request, Status};
use tracing::{debug, error, info, warn}; use tracing::{debug, error, info, warn};
+1
View File
@@ -10,6 +10,7 @@ use s3s::auth::Credentials;
use s3s::{dto::*, s3_error, S3Request, S3Result}; use s3s::{dto::*, s3_error, S3Request, S3Result};
use uuid::Uuid; use uuid::Uuid;
#[allow(dead_code)]
#[derive(Default, Clone)] #[derive(Default, Clone)]
struct ReqInfo { struct ReqInfo {
pub card: Option<Credentials>, pub card: Option<Credentials>,