From c8e9b04dd777f856857deed4e352065469aaa104 Mon Sep 17 00:00:00 2001
From: RWDai <27391645+RWDai@users.noreply.github.com>
Date: Fri, 6 Oct 2023 22:03:49 +0800
Subject: [PATCH] add package in process
---
Cargo.toml | 2 +-
admin/Cargo.toml | 26 ++
admin/README.md | 5 +
admin/config/conf-default.toml | 15 +
admin/src/api.rs | 3 +
admin/src/api/gateway_api.rs | 50 +++
admin/src/api/plugin_api.rs | 26 ++
admin/src/api/route_api.rs | 7 +
admin/src/config.rs | 43 +++
admin/src/constants.rs | 1 +
admin/src/dto.rs | 11 +
admin/src/dto/base_dto.rs | 23 ++
admin/src/dto/filter_dto.rs | 1 +
admin/src/dto/query_dto.rs | 44 +++
admin/src/initializer.rs | 18 ++
admin/src/main.rs | 18 ++
admin/src/service.rs | 3 +
admin/src/service/gateway_service.rs | 200 ++++++++++++
admin/src/service/helper.rs | 24 ++
admin/src/service/plugin_service.rs | 61 ++++
kernel-dto/src/constants.rs | 13 +
kernel-dto/src/dto.rs | 3 +
kernel-dto/src/dto/gateway_dto.rs | 292 ++++++++++++++++++
.../src/dto}/http_route_dto.rs | 0
.../src/dto}/plugin_filter_dto.rs | 24 +-
.../src/config => kernel-dto/src}/k8s_crd.rs | 1 +
kernel/Cargo.toml | 3 +-
kernel/res/spacegate-gateway.yaml | 12 +
kernel/src/config.rs | 9 +-
kernel/src/config/config_by_k8s.rs | 93 +++---
kernel/src/config/config_by_local.rs | 2 +-
kernel/src/config/config_by_redis.rs | 2 +-
kernel/src/config/gateway_dto.rs | 116 -------
kernel/src/constants.rs | 5 -
kernel/src/functions/http_client.rs | 3 +-
kernel/src/functions/http_route.rs | 9 +-
kernel/src/functions/server.rs | 2 +-
kernel/src/functions/websocket.rs | 2 +-
kernel/src/instance.rs | 10 +-
kernel/src/lib.rs | 2 +-
kernel/src/plugins/context.rs | 5 +-
kernel/src/plugins/filters.rs | 7 +-
kernel/src/plugins/filters/redirect.rs | 2 +-
kernel/src/plugins/filters/rewrite.rs | 2 +-
kernel/tests/test_file.rs | 58 ++++
45 files changed, 1060 insertions(+), 198 deletions(-)
create mode 100644 admin/Cargo.toml
create mode 100644 admin/README.md
create mode 100644 admin/config/conf-default.toml
create mode 100644 admin/src/api.rs
create mode 100644 admin/src/api/gateway_api.rs
create mode 100644 admin/src/api/plugin_api.rs
create mode 100644 admin/src/api/route_api.rs
create mode 100644 admin/src/config.rs
create mode 100644 admin/src/constants.rs
create mode 100644 admin/src/dto.rs
create mode 100644 admin/src/dto/base_dto.rs
create mode 100644 admin/src/dto/filter_dto.rs
create mode 100644 admin/src/dto/query_dto.rs
create mode 100644 admin/src/initializer.rs
create mode 100644 admin/src/main.rs
create mode 100644 admin/src/service.rs
create mode 100644 admin/src/service/gateway_service.rs
create mode 100644 admin/src/service/helper.rs
create mode 100644 admin/src/service/plugin_service.rs
create mode 100644 kernel-dto/src/constants.rs
create mode 100644 kernel-dto/src/dto.rs
create mode 100644 kernel-dto/src/dto/gateway_dto.rs
rename {kernel/src/config => kernel-dto/src/dto}/http_route_dto.rs (100%)
rename {kernel/src/config => kernel-dto/src/dto}/plugin_filter_dto.rs (64%)
rename {kernel/src/config => kernel-dto/src}/k8s_crd.rs (93%)
delete mode 100644 kernel/src/config/gateway_dto.rs
create mode 100644 kernel/tests/test_file.rs
diff --git a/Cargo.toml b/Cargo.toml
index 32494811..6bf801b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[workspace]
-members = ["kernel", "services/*"]
+members = ["kernel","kernel-dto","services/*","admin"]
resolver="2"
[profile.release]
diff --git a/admin/Cargo.toml b/admin/Cargo.toml
new file mode 100644
index 00000000..2fd08098
--- /dev/null
+++ b/admin/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+name = "spacegate-admin"
+version.workspace = true
+authors.workspace = true
+description.workspace = true
+keywords.workspace = true
+categories.workspace = true
+homepage.workspace = true
+documentation.workspace = true
+repository.workspace = true
+license.workspace = true
+edition.workspace = true
+readme = "./README.md"
+
+[features]
+k8s = ["kube", "k8s-openapi", "k8s-gateway-api","kernel-dto/k8s"]
+
+[dependencies]
+tardis = { workspace = true ,features = ["web-server"]}
+serde.workspace = true
+serde_json.workspace = true
+
+kernel-dto={path = "../kernel-dto",features = ["admin-support"]}
+kube = { workspace = true, optional = true }
+k8s-openapi = { workspace = true, optional = true }
+k8s-gateway-api = { workspace = true, optional = true }
\ No newline at end of file
diff --git a/admin/README.md b/admin/README.md
new file mode 100644
index 00000000..5ef22620
--- /dev/null
+++ b/admin/README.md
@@ -0,0 +1,5 @@
+---
+
+**spacegate admin serverđȘ**
+
+---
\ No newline at end of file
diff --git a/admin/config/conf-default.toml b/admin/config/conf-default.toml
new file mode 100644
index 00000000..35e3f039
--- /dev/null
+++ b/admin/config/conf-default.toml
@@ -0,0 +1,15 @@
+[fw]
+[fw.app]
+id = "spacegate-admin"
+name = "admin of spacegate"
+desc = "admin of spacegate"
+version = "0.1.0"
+default_lang = "zh-cn"
+
+
+[fw.web_server.modules.admin]
+title = "spacegate admin"
+doc_urls = [["test env", "http://localhost:9080/"],["remote env", "http://192.168.31.164:9080/"]]
+
+[fw.web_server]
+port = 9080
\ No newline at end of file
diff --git a/admin/src/api.rs b/admin/src/api.rs
new file mode 100644
index 00000000..337d5081
--- /dev/null
+++ b/admin/src/api.rs
@@ -0,0 +1,3 @@
+pub(crate) mod gateway_api;
+pub(crate) mod plugin_api;
+pub(crate) mod route_api;
diff --git a/admin/src/api/gateway_api.rs b/admin/src/api/gateway_api.rs
new file mode 100644
index 00000000..440c3ad9
--- /dev/null
+++ b/admin/src/api/gateway_api.rs
@@ -0,0 +1,50 @@
+use crate::dto::base_dto::CommonPageDto;
+use crate::dto::query_dto::GatewayQueryDto;
+use crate::service::gateway_service::GatewayService;
+use kernel_dto::dto::gateway_dto::SgGateway;
+use tardis::web::poem_openapi;
+use tardis::web::poem_openapi::param::Query;
+use tardis::web::poem_openapi::payload::Json;
+use tardis::web::web_resp::{TardisApiResult, TardisPage, TardisResp, Void};
+
+#[derive(Clone, Default)]
+pub struct GatewayApi;
+
+/// Gateway API
+#[poem_openapi::OpenApi(prefix_path = "/gateway")]
+impl GatewayApi {
+ /// Get Gateway List
+ #[oai(path = "/", method = "get")]
+ async fn list(
+ &self,
+ name: Query