1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Split the full config with partial configs used by some sub-commands

This commit is contained in:
Quentin Gliech
2023-06-26 17:03:16 +02:00
parent dec9310a32
commit 8c42563e61
18 changed files with 135 additions and 23 deletions

View File

@ -15,7 +15,7 @@
use std::collections::HashSet;
use clap::Parser;
use mas_config::{ConfigurationSection, RootConfig};
use mas_config::{ConfigurationSection, RootConfig, SyncConfig};
use mas_storage::{
upstream_oauth2::UpstreamOAuthProviderRepository, Repository, RepositoryAccess, SystemClock,
};
@ -142,7 +142,7 @@ async fn sync(root: &super::Options, prune: bool, dry_run: bool) -> anyhow::Resu
let mut rng = rand_chacha::ChaChaRng::from_entropy();
let clock = SystemClock::default();
let config: RootConfig = root.load_config()?;
let config: SyncConfig = root.load_config()?;
let encrypter = config.secrets.encrypter();
let pool = database_from_config(&config.database).await?;
let mut repo = PgRepository::from_pool(&pool).await?.boxed();

View File

@ -74,7 +74,7 @@ impl Options {
}
}
pub fn load_config<'de, T: ConfigurationSection<'de>>(&self) -> anyhow::Result<T> {
pub fn load_config<T: ConfigurationSection>(&self) -> anyhow::Result<T> {
let configs = if self.config.is_empty() {
// Read the MAS_CONFIG environment variable
std::env::var("MAS_CONFIG")

View File

@ -17,7 +17,7 @@ use std::{sync::Arc, time::Duration};
use anyhow::Context;
use clap::Parser;
use itertools::Itertools;
use mas_config::RootConfig;
use mas_config::AppConfig;
use mas_handlers::{AppState, HttpClientFactory, MatrixHomeserver};
use mas_listener::{server::Server, shutdown::ShutdownStream};
use mas_matrix_synapse::SynapseConnection;
@ -54,7 +54,7 @@ impl Options {
#[allow(clippy::too_many_lines)]
pub async fn run(self, root: &super::Options) -> anyhow::Result<()> {
let span = info_span!("cli.run.init").entered();
let config: RootConfig = root.load_config()?;
let config: AppConfig = root.load_config()?;
// Connect to the database
info!("Connecting to the database");

View File

@ -13,7 +13,7 @@
// limitations under the License.
use clap::Parser;
use mas_config::RootConfig;
use mas_config::AppConfig;
use mas_handlers::HttpClientFactory;
use mas_matrix_synapse::SynapseConnection;
use mas_router::UrlBuilder;
@ -31,7 +31,7 @@ pub(super) struct Options {}
impl Options {
pub async fn run(self, root: &super::Options) -> anyhow::Result<()> {
let span = info_span!("cli.worker.init").entered();
let config: RootConfig = root.load_config()?;
let config: AppConfig = root.load_config()?;
// Connect to the database
info!("Connecting to the database");