From f6655c9017aea59a1ce622a2e9f01d74676a27f7 Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:55:48 +0800 Subject: [PATCH] fix --- admin/src/api/plugin_api.rs | 23 +++++++++++-------- .../src/model/vo_converter/gateway_vo_conv.rs | 13 +++++++---- admin/src/service/gateway_service.rs | 4 ++-- .../src/converter/gateway_k8s_conv.rs | 6 ++--- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/admin/src/api/plugin_api.rs b/admin/src/api/plugin_api.rs index a269726d..a97ed616 100644 --- a/admin/src/api/plugin_api.rs +++ b/admin/src/api/plugin_api.rs @@ -1,4 +1,4 @@ -use crate::model::query_dto::PluginQueryDto; +use crate::model::query_dto::{PluginQueryDto, ToInstance}; use crate::model::vo::plugin_vo::SgFilterVO; use crate::service::plugin_service::PluginVoService; use tardis::web::poem_openapi; @@ -23,15 +23,18 @@ impl PluginApi { target_kind: Query>, target_namespace: Query>, ) -> TardisApiResult { - let _ = PluginVoService::list(PluginQueryDto { - ids: ids.0.map(|s| s.split(',').map(|s| s.to_string()).collect::>()), - name: name.0, - namespace: namespace.0, - code: code.0, - target_name: target_name.0, - target_kind: target_kind.0, - target_namespace: target_namespace.0, - }) + let _ = PluginVoService::list( + PluginQueryDto { + ids: ids.0.map(|s| s.split(',').map(|s| s.to_string()).collect::>()), + name: name.0, + namespace: namespace.0, + code: code.0, + target_name: target_name.0, + target_kind: target_kind.0, + target_namespace: target_namespace.0, + } + .to_instance()?, + ) .await; TardisResp::ok(Void {}) } diff --git a/admin/src/model/vo_converter/gateway_vo_conv.rs b/admin/src/model/vo_converter/gateway_vo_conv.rs index 0834d10d..9439aafc 100644 --- a/admin/src/model/vo_converter/gateway_vo_conv.rs +++ b/admin/src/model/vo_converter/gateway_vo_conv.rs @@ -1,4 +1,4 @@ -use crate::model::query_dto::PluginQueryDto; +use crate::model::query_dto::{PluginQueryDto, ToInstance}; use crate::model::vo::gateway_vo::{SgGatewayVO, SgListenerVO, SgTlsConfigVO}; use crate::model::vo::plugin_vo::SgFilterVO; use crate::model::vo_converter::VoConv; @@ -17,10 +17,13 @@ impl VoConv for SgGatewayVO { let filters = if !self.filters.is_empty() { Some( join_all( - PluginVoService::list(PluginQueryDto { - ids: Some(self.filters), - ..Default::default() - }) + PluginVoService::list( + PluginQueryDto { + ids: Some(self.filters), + ..Default::default() + } + .to_instance()?, + ) .await? .into_iter() .map(|f| f.to_model()) diff --git a/admin/src/service/gateway_service.rs b/admin/src/service/gateway_service.rs index f7d65a0f..47c3a9de 100644 --- a/admin/src/service/gateway_service.rs +++ b/admin/src/service/gateway_service.rs @@ -39,7 +39,7 @@ impl GatewayVoService { #[cfg(feature = "k8s")] { let (namespace, _) = parse_k8s_obj_unique(&add.get_unique_name()); - let (gateway, _, sgfilters) = add_model.to_kube_gateway(); + let (gateway, sgfilters) = add_model.to_kube_gateway(); let gateway_api: Api = Api::namespaced(get_k8s_client().await?, &namespace); @@ -63,7 +63,7 @@ impl GatewayVoService { { let (namespace, name) = parse_k8s_obj_unique(update_un); let gateway_api: Api = Api::namespaced(get_k8s_client().await?, &namespace); - let (update_gateway, update_secret, update_filter) = update_sg_gateway.to_kube_gateway(); + let (update_gateway, update_filter) = update_sg_gateway.to_kube_gateway(); gateway_api.replace(&name, &PostParams::default(), &update_gateway).await.warp_result_by_method("Replace Gateway")?; //todo update filter ref diff --git a/kernel-common/src/converter/gateway_k8s_conv.rs b/kernel-common/src/converter/gateway_k8s_conv.rs index 39edc9ad..166273ab 100644 --- a/kernel-common/src/converter/gateway_k8s_conv.rs +++ b/kernel-common/src/converter/gateway_k8s_conv.rs @@ -15,11 +15,9 @@ use tardis::basic::result::TardisResult; use tardis::futures_util::future::join_all; impl SgGateway { - pub fn to_kube_gateway(self) -> (Gateway, Vec, Vec) { + pub fn to_kube_gateway(self) -> (Gateway, Vec) { let (namespace, raw_name) = parse_k8s_obj_unique(&self.name); - let mut secrets: Vec = vec![]; - let gateway = Gateway { metadata: ObjectMeta { annotations: Some(self.parameters.to_kube_gateway()), @@ -83,7 +81,7 @@ impl SgGateway { vec![] }; - (gateway, secrets, sgfilters) + (gateway, sgfilters) } pub async fn from_kube_gateway(gateway: Gateway) -> TardisResult {