Module config

Module config 

Source
Expand description

Config-file loaders for cli.toml and server.toml.

This module owns three concerns:

  1. Paths — XDG-resolved defaults via get_default_config_path, with per-binary overrides from MANTA_CLI_CONFIG / MANTA_SERVER_CONFIG. See get_cli_config_file_path and get_server_config_file_path.
  2. Loadingget_cli_configuration and get_server_configuration parse the TOML file and merge any MANTA_*-prefixed environment variables on top, returning an untyped ::config::Config. The typed deserialisation targets live with each binary (CliConfiguration in manta-cli, ServerConfiguration in manta-server) so this module stays agnostic of either schema.
  3. In-place editingread_config_toml / write_config_toml expose a toml_edit::DocumentMut view for manta config set and friends, preserving comments and formatting.

Missing-file errors are intentionally rich: the MantaError::NotFound message includes a minimal example file and, when a legacy ~/.config/manta/config.toml is detected, a field-by-field migration mapping.

Functions§

get_cli_config_file_path
Returns the CLI config file path, honoring MANTA_CLI_CONFIG if set.
get_cli_configuration
Load cli.toml. Fails loudly if the file is missing; the error message includes a minimal example and (when a legacy config.toml is detected) a field-by-field migration mapping.
get_csm_root_cert_content
Read the root CA certificate from file_path, falling back to the default config directory if the path is relative.
get_default_cache_path
Returns the default manta cache directory path (e.g. ~/.cache/manta/).
get_default_config_path
Returns the default manta config directory path (e.g. ~/.config/manta/).
get_default_manta_cli_config_file_path
Returns the default CLI config file path (e.g. ~/.config/manta/cli.toml).
get_default_manta_config_file_path
Returns the path of the legacy unified config file (e.g. ~/.config/manta/config.toml). Used only by missing_config_message to detect when a user is migrating from the pre-split layout — neither binary ever reads from this path at startup.
get_default_manta_server_config_file_path
Returns the default server config file path (e.g. ~/.config/manta/server.toml).
get_server_config_file_path
Returns the server config file path, honoring MANTA_SERVER_CONFIG if set.
get_server_configuration
Load server.toml. Fails loudly if the file is missing; the error message includes a minimal example and (when a legacy config.toml is detected) a field-by-field migration mapping.
read_config_toml
Reads the manta CLI configuration file (cli.toml) and parses it as TOML, honoring MANTA_CLI_CONFIG.
write_config_toml
Writes a DocumentMut back to the manta configuration file.