only validate latest config files
This commit is contained in:
parent
3a57eb5880
commit
7da5b5ce46
1 changed files with 15 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
//! `config validate` subcommand
|
||||
|
||||
use crate::config::{client, server, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH};
|
||||
use crate::{
|
||||
command::config::{next_revision, RevisionCheckError},
|
||||
config::{client, server, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH},
|
||||
};
|
||||
use color_print::cprintln;
|
||||
use std::{fs, io::Read};
|
||||
use validator::Validate;
|
||||
|
@ -9,6 +12,10 @@ use validator::Validate;
|
|||
pub(crate) enum ValidationError {
|
||||
#[error(transparent)]
|
||||
ReadFile(#[from] std::io::Error),
|
||||
#[error(transparent)]
|
||||
UnknownRevision(#[from] RevisionCheckError),
|
||||
#[error("config files are not the latest revision")]
|
||||
OutOfDate,
|
||||
#[error("invalid config file")]
|
||||
InvalidConfig,
|
||||
}
|
||||
|
@ -22,6 +29,13 @@ enum ReadError {
|
|||
}
|
||||
|
||||
pub(super) fn run() -> Result<(), ValidationError> {
|
||||
if next_revision()?.is_some() {
|
||||
cprintln!(
|
||||
"Please first run `<bold>fishctl config migrate</>` to update your config files."
|
||||
);
|
||||
return Err(ValidationError::OutOfDate);
|
||||
}
|
||||
|
||||
let server_validation_result = match read_server_toml() {
|
||||
Ok(config) => config.validate().map_err(|err| {
|
||||
cprintln!("<r!><bold>config/server.toml is invalid.</></>\n{}", err);
|
||||
|
|
Loading…
Reference in a new issue