This commit is contained in:
naskya 2024-06-21 13:16:16 +09:00
parent 924cfcf22c
commit 701cf74693
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
6 changed files with 11 additions and 10 deletions

View file

@ -76,8 +76,10 @@ fishctl config update
### Validate the config files ### 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 ```sh
fishctl config validate 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.

View file

@ -3,7 +3,7 @@
mod update; mod update;
mod validate; 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 clap::Subcommand;
use serde::Deserialize; use serde::Deserialize;
use std::{ use std::{
@ -68,7 +68,7 @@ where
} }
fn current_revision() -> Result<Revision, RevisionCheckError> { 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 server_config_exists = Path::new(SERVER_CONFIG_PATH).is_file();
let client_config_exists = Path::new(CLIENT_CONFIG_PATH).is_file(); let client_config_exists = Path::new(CLIENT_CONFIG_PATH).is_file();

View file

@ -3,7 +3,7 @@
use crate::{ use crate::{
command::config::{read_file_as_string, ReadError}, 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 color_print::cprintln;
use sqlx::{postgres::PgConnectOptions, ConnectOptions}; use sqlx::{postgres::PgConnectOptions, ConnectOptions};
@ -19,7 +19,7 @@ use yaml_rust::{Yaml, YamlLoader};
/// Errors that can happen in `config update v1` subcommand /// Errors that can happen in `config update v1` subcommand
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub(crate) enum Error { 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), ReadYaml(#[from] ReadYamlConfigError),
#[error(transparent)] #[error(transparent)]
WriteToml(#[from] WriteTomlConfigError), WriteToml(#[from] WriteTomlConfigError),
@ -58,7 +58,7 @@ pub(crate) enum WriteTomlConfigError {
} }
fn read_default_yml() -> Result<HashMap<String, Yaml>, ReadYamlConfigError> { 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() { if content.is_empty() {
return Err(ReadYamlConfigError::InvalidConfig( return Err(ReadYamlConfigError::InvalidConfig(

View file

@ -5,7 +5,7 @@
// Optional values are handled in the main Firefish program, and this tool // Optional values are handled in the main Firefish program, and this tool
// does not take care of it. // does not take care of it.
use super::{ensure_latest_revision, Revision}; use crate::config::{ensure_latest_revision, Revision};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use validator::{Validate, ValidationError}; use validator::{Validate, ValidationError};

View file

@ -10,7 +10,6 @@ use validator::ValidationError;
pub(crate) const SERVER_CONFIG_PATH: &str = "config/server.toml"; pub(crate) const SERVER_CONFIG_PATH: &str = "config/server.toml";
pub(crate) const CLIENT_CONFIG_PATH: &str = "config/client.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)] #[derive(Deserialize_repr, Serialize_repr, PartialEq, Clone, ValueEnum, Sequence, Debug)]
#[clap(rename_all = "lowercase")] #[clap(rename_all = "lowercase")]
@ -19,7 +18,7 @@ pub enum Revision {
#[clap(skip)] #[clap(skip)]
/// Misskey-style config (`.config/default.yml`) /// Misskey-style config (`.config/default.yml`)
V0, V0,
/// The first revision number for `config/{server,client}.toml` /// The first revision for `config/{server,client}.toml`
V1, V1,
} }

View file

@ -5,7 +5,7 @@
// Optional values are handled in the main Firefish program, and this tool // Optional values are handled in the main Firefish program, and this tool
// does not take care of it. // does not take care of it.
use super::{ensure_latest_revision, Revision}; use crate::config::{ensure_latest_revision, Revision};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use validator::Validate; use validator::Validate;