feat: harden community production foundation through story 1.5
This commit is contained in:
1 parent
c30461cc92
commit
f6fc2e5c9b
161 files changed
+16758
-2515
No files matched your search
@@ -0,0 +1,47 @@
|
||||
use crate::{
|
||||
ConfigError, ConfigSource, DatabaseSettings, DeprecationRecord, fingerprint::sha256_hex,
|
||||
process::parse_database_source,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MigratorConfig {
|
||||
pub database: DatabaseSettings,
|
||||
fingerprint: String,
|
||||
deprecations: Vec<DeprecationRecord>,
|
||||
}
|
||||
|
||||
impl MigratorConfig {
|
||||
pub fn fingerprint(&self) -> &str {
|
||||
&self.fingerprint
|
||||
}
|
||||
|
||||
pub fn deprecations(&self) -> &[DeprecationRecord] {
|
||||
&self.deprecations
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_migrator(source: ConfigSource) -> Result<MigratorConfig, ConfigError> {
|
||||
let (database, deprecations) = parse_database_source(source.retain_for_migrator())?;
|
||||
let fingerprint = sha256_hex([
|
||||
"schema=crank-config-migrator-v1".to_owned(),
|
||||
format!("url={}", database.url.is_some()),
|
||||
format!("host={}", database.host.to_ascii_lowercase()),
|
||||
format!("port={}", database.port),
|
||||
format!("database={}", database.database),
|
||||
format!("username={}", database.username),
|
||||
format!("password={}", database.password.is_configured()),
|
||||
format!(
|
||||
"pool={}:{}:{}:{}:{}",
|
||||
database.pool.max_connections,
|
||||
database.pool.min_connections,
|
||||
database.pool.acquire_timeout_ms,
|
||||
database.pool.idle_timeout_ms,
|
||||
database.pool.max_lifetime_ms
|
||||
),
|
||||
]);
|
||||
Ok(MigratorConfig {
|
||||
database,
|
||||
fingerprint,
|
||||
deprecations,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user