WIP
This commit is contained in:
parent
924cfcf22c
commit
701cf74693
6 changed files with 11 additions and 10 deletions
|
@ -76,8 +76,10 @@ fishctl config update
|
|||
|
||||
### Validate the config files
|
||||
|
||||
To validate the config files, run the following command. Note that this only performs a formal validation and does not check that the settings are appropriate. For example, this command does not check if the database password is correct.
|
||||
Execute the following command to validate the config files.
|
||||
|
||||
```sh
|
||||
fishctl config validate
|
||||
```
|
||||
|
||||
Note that this only performs a formal validation and does not check that the settings are appropriate. For example, this command does not check if the database password is correct.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
mod update;
|
||||
mod validate;
|
||||
|
||||
use crate::config::{Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH};
|
||||
use crate::config::{Revision, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH};
|
||||
use clap::Subcommand;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
|
@ -68,7 +68,7 @@ where
|
|||
}
|
||||
|
||||
fn current_revision() -> Result<Revision, RevisionCheckError> {
|
||||
let old_config_exists = Path::new(OLD_CONFIG_PATH).is_file();
|
||||
let old_config_exists = Path::new(".config/default.yml").is_file();
|
||||
let server_config_exists = Path::new(SERVER_CONFIG_PATH).is_file();
|
||||
let client_config_exists = Path::new(CLIENT_CONFIG_PATH).is_file();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use crate::{
|
||||
command::config::{read_file_as_string, ReadError},
|
||||
config::{client, server, Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH},
|
||||
config::{client, server, Revision, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH},
|
||||
};
|
||||
use color_print::cprintln;
|
||||
use sqlx::{postgres::PgConnectOptions, ConnectOptions};
|
||||
|
@ -19,7 +19,7 @@ use yaml_rust::{Yaml, YamlLoader};
|
|||
/// Errors that can happen in `config update v1` subcommand
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub(crate) enum Error {
|
||||
#[error("failed to parse the old config file ({})", OLD_CONFIG_PATH)]
|
||||
#[error("failed to parse the old config file (.config/default.yml)")]
|
||||
ReadYaml(#[from] ReadYamlConfigError),
|
||||
#[error(transparent)]
|
||||
WriteToml(#[from] WriteTomlConfigError),
|
||||
|
@ -58,7 +58,7 @@ pub(crate) enum WriteTomlConfigError {
|
|||
}
|
||||
|
||||
fn read_default_yml() -> Result<HashMap<String, Yaml>, ReadYamlConfigError> {
|
||||
let content = YamlLoader::load_from_str(&read_file_as_string(OLD_CONFIG_PATH)?)?;
|
||||
let content = YamlLoader::load_from_str(&read_file_as_string(".config/default.yml")?)?;
|
||||
|
||||
if content.is_empty() {
|
||||
return Err(ReadYamlConfigError::InvalidConfig(
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Optional values are handled in the main Firefish program, and this tool
|
||||
// does not take care of it.
|
||||
|
||||
use super::{ensure_latest_revision, Revision};
|
||||
use crate::config::{ensure_latest_revision, Revision};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::{Validate, ValidationError};
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ use validator::ValidationError;
|
|||
|
||||
pub(crate) const SERVER_CONFIG_PATH: &str = "config/server.toml";
|
||||
pub(crate) const CLIENT_CONFIG_PATH: &str = "config/client.toml";
|
||||
pub(crate) const OLD_CONFIG_PATH: &str = ".config/default.yml";
|
||||
|
||||
#[derive(Deserialize_repr, Serialize_repr, PartialEq, Clone, ValueEnum, Sequence, Debug)]
|
||||
#[clap(rename_all = "lowercase")]
|
||||
|
@ -19,7 +18,7 @@ pub enum Revision {
|
|||
#[clap(skip)]
|
||||
/// Misskey-style config (`.config/default.yml`)
|
||||
V0,
|
||||
/// The first revision number for `config/{server,client}.toml`
|
||||
/// The first revision for `config/{server,client}.toml`
|
||||
V1,
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Optional values are handled in the main Firefish program, and this tool
|
||||
// does not take care of it.
|
||||
|
||||
use super::{ensure_latest_revision, Revision};
|
||||
use crate::config::{ensure_latest_revision, Revision};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
|
|
Loading…
Reference in a new issue