[chore](trx-rs): drop legacy ~/.trx-{server,client}.toml search paths
Remove the home-directory dotfile paths that predate the XDG layout. Search order is now: CWD → ~/.config/trx-rs/ → /etc/trx-rs/, checked for both the combined trx-rs.toml and the per-binary flat file at each tier. Update doc comments and tests accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -6,10 +6,9 @@
|
||||
//!
|
||||
//! Supports loading configuration from TOML files with the following search order:
|
||||
//! 1. Path specified via `--config` CLI argument
|
||||
//! 2. `./trx-client.toml` (current directory)
|
||||
//! 3. `~/.trx-client.toml` (home directory)
|
||||
//! 4. `~/.config/trx-rs/client.toml` (XDG config)
|
||||
//! 5. `/etc/trx-rs/client.toml` (system-wide)
|
||||
//! 2. `./trx-rs.toml` `[trx-client]` section, or `./trx-client.toml`
|
||||
//! 3. `~/.config/trx-rs/trx-rs.toml` `[trx-client]` section, or `~/.config/trx-rs/client.toml`
|
||||
//! 4. `/etc/trx-rs/trx-rs.toml` `[trx-client]` section, or `/etc/trx-rs/client.toml`
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::net::IpAddr;
|
||||
@@ -488,9 +487,6 @@ impl ConfigFile for ClientConfig {
|
||||
fn default_search_paths() -> Vec<PathBuf> {
|
||||
let mut paths = Vec::new();
|
||||
paths.push(PathBuf::from("trx-client.toml"));
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
paths.push(home_dir.join(".trx-client.toml"));
|
||||
}
|
||||
if let Some(config_dir) = dirs::config_dir() {
|
||||
paths.push(config_dir.join("trx-rs").join("client.toml"));
|
||||
}
|
||||
@@ -551,9 +547,11 @@ port = 8080
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_example_toml_parses() {
|
||||
let example = ClientConfig::example_toml();
|
||||
let _config: ClientConfig = toml::from_str(&example).unwrap();
|
||||
fn test_example_combined_toml_parses() {
|
||||
let example = ClientConfig::example_combined_toml();
|
||||
let table: toml::Table = toml::from_str(&example).unwrap();
|
||||
let section = toml::to_string(table.get("trx-client").unwrap()).unwrap();
|
||||
let _config: ClientConfig = toml::from_str(§ion).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
//!
|
||||
//! Supports loading configuration from TOML files with the following search order:
|
||||
//! 1. Path specified via `--config` CLI argument
|
||||
//! 2. `./trx-server.toml` (current directory)
|
||||
//! 3. `~/.trx-server.toml` (legacy per-user path)
|
||||
//! 4. `~/.config/trx-rs/server.toml` (XDG config)
|
||||
//! 5. `/etc/trx-rs/server.toml` (system-wide)
|
||||
//! 2. `./trx-rs.toml` `[trx-server]` section, or `./trx-server.toml`
|
||||
//! 3. `~/.config/trx-rs/trx-rs.toml` `[trx-server]` section, or `~/.config/trx-rs/server.toml`
|
||||
//! 4. `/etc/trx-rs/trx-rs.toml` `[trx-server]` section, or `/etc/trx-rs/server.toml`
|
||||
|
||||
use std::net::IpAddr;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -801,9 +800,6 @@ impl ConfigFile for ServerConfig {
|
||||
fn default_search_paths() -> Vec<PathBuf> {
|
||||
let mut paths = Vec::new();
|
||||
paths.push(PathBuf::from("trx-server.toml"));
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
paths.push(home_dir.join(".trx-server.toml"));
|
||||
}
|
||||
if let Some(config_dir) = dirs::config_dir() {
|
||||
paths.push(config_dir.join("trx-rs").join("server.toml"));
|
||||
}
|
||||
@@ -907,9 +903,11 @@ tokens = ["secret123"]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_example_toml_parses() {
|
||||
let example = ServerConfig::example_toml();
|
||||
let _config: ServerConfig = toml::from_str(&example).unwrap();
|
||||
fn test_example_combined_toml_parses() {
|
||||
let example = ServerConfig::example_combined_toml();
|
||||
let table: toml::Table = toml::from_str(&example).unwrap();
|
||||
let section = toml::to_string(table.get("trx-server").unwrap()).unwrap();
|
||||
let _config: ServerConfig = toml::from_str(§ion).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -945,14 +943,6 @@ tokens = ["secret123"]
|
||||
assert!(config.validate().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_search_paths_include_legacy_home_file() {
|
||||
let paths = ServerConfig::default_search_paths();
|
||||
if let Some(home_dir) = dirs::home_dir() {
|
||||
assert!(paths.contains(&home_dir.join(".trx-server.toml")));
|
||||
}
|
||||
}
|
||||
|
||||
// --- SDR-11: validate_sdr() unit tests ---
|
||||
|
||||
fn sdr_config_with_access(args: &str) -> ServerConfig {
|
||||
|
||||
Reference in New Issue
Block a user