chore: liveness as struct rather than a json string

This commit is contained in:
Jesús Pérez Lorenzo 2021-10-14 15:03:23 +01:00
parent 7bf17a73ad
commit 882ea24dea

View File

@ -15,7 +15,7 @@ use kloud::{
};
use clds::clouds::defs::{Cloud};
use crate::defs::{DataDBs}; // ,CollsData};
use clds::clouds::on_clouds::{on_cloud_req,on_cloud_name_req,get_cloud_check,get_apps_check};
use clds::clouds::on_clouds::{on_cloud_req,on_cloud_name_req_info,get_cloud_check,get_apps_check};
pub async fn cloud_req(reqname: &str,cloud: &Cloud,reqenv: &ReqEnv,opts: &KloudQueryConfigFilters) -> String {
let mut result: String;
@ -23,12 +23,14 @@ pub async fn cloud_req(reqname: &str,cloud: &Cloud,reqenv: &ReqEnv,opts: &KloudQ
let mut apps_result = String::from("");
if opts.grp.is_empty() {
result = on_cloud_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&opts.cld).await;
} else if opts.name.is_empty() {
let source = format!("{}/{}",&opts.cld,&opts.grp);
result = on_cloud_name_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&source).await;
} else {
let source = format!("{}/{}/{}",&opts.cld,&opts.grp,&opts.name);
result = on_cloud_name_req(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&source).await;
let source: String;
if opts.name.is_empty() {
source = format!("{}/{}",&opts.cld,&opts.grp);
} else {
source = format!("{}/{}/{}",&opts.cld,&opts.grp,&opts.name);
}
result = on_cloud_name_req_info(&reqname,&cloud,&reqenv,&opts.tsksrvcs,&opts.srvrs,&source).await;
}
if opts.tsksrvcs.contains("liveness") {
liveness_result = get_cloud_check(&reqenv).await;
@ -37,26 +39,7 @@ pub async fn cloud_req(reqname: &str,cloud: &Cloud,reqenv: &ReqEnv,opts: &KloudQ
apps_result = get_apps_check(&reqenv).await;
}
result = format!("{}:{}{}:{}{}:{}{}",r#"{"req""#,&result,r#","apps""#,&apps_result,r#","liveness""#,&liveness_result,r#"}"#);
match reqname {
"config" => {
result.to_owned()
},
"status" => {
result.to_owned()
},
"provision" => {
result.to_owned()
},
"liveness" => {
result.to_owned()
},
"apps" => {
result.to_owned()
},
_ => {
result.to_owned()
}
}
result.to_owned()
}
pub async fn config (
opts: KloudQueryConfigFilters,