Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RWDai committed Nov 8, 2023
1 parent 4483fb5 commit f6655c9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
23 changes: 13 additions & 10 deletions admin/src/api/plugin_api.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -23,15 +23,18 @@ impl PluginApi {
target_kind: Query<Option<String>>,
target_namespace: Query<Option<String>>,
) -> TardisApiResult<Void> {
let _ = PluginVoService::list(PluginQueryDto {
ids: ids.0.map(|s| s.split(',').map(|s| s.to_string()).collect::<Vec<String>>()),
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::<Vec<String>>()),
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 {})
}
Expand Down
13 changes: 8 additions & 5 deletions admin/src/model/vo_converter/gateway_vo_conv.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,10 +17,13 @@ impl VoConv<SgGateway, SgGatewayVO> 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())
Expand Down
4 changes: 2 additions & 2 deletions admin/src/service/gateway_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gateway> = Api::namespaced(get_k8s_client().await?, &namespace);

Expand All @@ -63,7 +63,7 @@ impl GatewayVoService {
{
let (namespace, name) = parse_k8s_obj_unique(update_un);
let gateway_api: Api<Gateway> = 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
Expand Down
6 changes: 2 additions & 4 deletions kernel-common/src/converter/gateway_k8s_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Secret>, Vec<SgSingeFilter>) {
pub fn to_kube_gateway(self) -> (Gateway, Vec<SgSingeFilter>) {
let (namespace, raw_name) = parse_k8s_obj_unique(&self.name);

let mut secrets: Vec<Secret> = vec![];

let gateway = Gateway {
metadata: ObjectMeta {
annotations: Some(self.parameters.to_kube_gateway()),
Expand Down Expand Up @@ -83,7 +81,7 @@ impl SgGateway {
vec![]
};

(gateway, secrets, sgfilters)
(gateway, sgfilters)
}

pub async fn from_kube_gateway(gateway: Gateway) -> TardisResult<SgGateway> {
Expand Down

0 comments on commit f6655c9

Please sign in to comment.