/// Read the config from the given path and apply it to the database.
/// If the dryrun flag is set, the changes will not be applied.
Read the config from the given path and apply it to the database.
If the dryrun flag is set, the changes will not be applied.
Read the config from the given path and apply it to the database . If the dryrun flag is set the changes will not be applied .
pub fn apply(target: &Path, dryrun: bool) -> Result<()> {
    let target = target.to_path_buf();
    if target.is_dir() {
        return Err(anyhow!(
            "directory is not supported yet ({})",
            target.display()
        ));
    }
    let config = Config::new(&target)?;
    info!("Applying configuration:\n{}", config);
    let mut conn = DbConnection::new(&config);
    let users_in_db = conn.get_users()?;
    let users_in_config = config.users.clone();
    // Apply users changes (new users, update password)
    create_or_update_users(&mut conn, &users_in_db, &users_in_config, dryrun)?;
    // Apply roles privileges to cluster (database role, schema role, table role)
    create_or_update_privileges(&mut conn, &config, dryrun)?;
    Ok(())
}
pub fn apply ( target : & Path , dryrun : bool ) -> Result < ( ) > { let target = target . to_path_buf ( ) ; if target . is_dir ( ) { return Err ( anyhow ! ( " " target display ( ) ) ) ; } let config = Config :: new ( & target ) ? ; info ! ( " \n " config ) ; let mut conn = DbConnection :: new ( & config ) ; let users_in_db = conn . get_users ( ) ? ; let users_in_config = config . users . clone ( ) ; // Apply users changes (new users, update password) create_or_update_users ( & mut conn , & users_in_db , & users_in_config , dryrun ) ? ; // Apply roles privileges to cluster (database role, schema role, table role) create_or_update_privileges ( & mut conn , & config , dryrun ) ? ; Ok ( ( ) ) }
Read the config from the given path and apply it to the database.
Read the config from the given path and apply it to the database .
target
&Path
dryrun
bool