feat: check the remote profile
This commit is contained in:
parent
28a4386975
commit
9694af82f4
@ -1,6 +1,7 @@
|
|||||||
use crate::utils::{dirs, help, tmpl};
|
use crate::utils::{dirs, help, tmpl};
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_yaml::Mapping;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
@ -228,6 +229,11 @@ impl PrfItem {
|
|||||||
let name = name.unwrap_or(uid.clone());
|
let name = name.unwrap_or(uid.clone());
|
||||||
let data = resp.text_with_charset("utf-8").await?;
|
let data = resp.text_with_charset("utf-8").await?;
|
||||||
|
|
||||||
|
// check the data whether the valid yaml format
|
||||||
|
if !serde_yaml::from_str::<Mapping>(&data).is_ok() {
|
||||||
|
bail!("the remote profile data is not valid yaml");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(PrfItem {
|
Ok(PrfItem {
|
||||||
uid: Some(uid),
|
uid: Some(uid),
|
||||||
itype: Some("remote".into()),
|
itype: Some("remote".into()),
|
||||||
|
Loading…
Reference in New Issue
Block a user