forked from ideal-world/spacegate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove admin k8s feature(in progress)
- Loading branch information
Showing
23 changed files
with
536 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use crate::model::vo::spacegate_inst_vo::InstConfigVo; | ||
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, TardisResp, Void}; | ||
|
||
#[derive(Clone, Default)] | ||
pub struct SpacegateManageApi; | ||
|
||
#[poem_openapi::OpenApi(prefix_path = "/spacegate/manage")] | ||
impl SpacegateManageApi { | ||
/// List Spacegate Inst | ||
#[oai(path = "/", method = "get")] | ||
async fn list(&self) -> TardisApiResult<Vec<InstConfigVo>> { | ||
SpacegateManageService::list().await?; | ||
} | ||
|
||
/// Add Spacegate Inst | ||
#[oai(path = "/", method = "post")] | ||
async fn add(&self, add: Json<InstConfigVo>) -> TardisApiResult<Void> { | ||
// HttpRouteVoService::add(add.0).await?; | ||
TardisResp::ok(Void {}) | ||
} | ||
|
||
/// Update Spacegate Inst | ||
#[oai(path = "/", method = "put")] | ||
async fn update(&self, backend: Json<InstConfigVo>) -> TardisApiResult<Void> { | ||
// HttpRouteVoService::update(backend.0).await?; | ||
TardisResp::ok(Void {}) | ||
} | ||
|
||
/// Delete Spacegate Inst | ||
#[oai(path = "/", method = "delete")] | ||
async fn delete(&self, name: Query<String>) -> TardisApiResult<Void> { | ||
// HttpRouteVoService::delete(&name.0).await?; | ||
TardisResp::ok(Void {}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use crate::config::k8s_config::ToKubeconfig; | ||
use crate::model::vo::spacegate_inst_vo::K8sClusterConfig; | ||
use kube::config::Kubeconfig; | ||
use lazy_static::lazy_static; | ||
use std::mem; | ||
use std::sync::RwLock; | ||
use tardis::basic::error::TardisError; | ||
use tardis::basic::result::TardisResult; | ||
|
||
lazy_static! { | ||
///Total kube config | ||
pub static ref KUBECONFIG: RwLock<kube::config::Kubeconfig> = RwLock::default(); | ||
} | ||
|
||
pub fn add_k8s_config(config: K8sClusterConfig) -> TardisResult<()> { | ||
for _ in 0..100 { | ||
if let Ok(mut kube_config) = KUBECONFIG.try_write() { | ||
let mut swap_config = Kubeconfig::default(); | ||
mem::swap(&mut swap_config, &mut kube_config); | ||
swap_config = swap_config.merge(config.to_kubeconfig()).map_err(|e| TardisError::wrap(&format!("kubeconfig parse error:{e}"), ""))?; | ||
|
||
mem::swap(&mut swap_config, &mut kube_config); | ||
return Ok(()); | ||
}; | ||
} | ||
|
||
Err(TardisError::conflict("[SG.admin] add config: get lock time out", "")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.