Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion refinery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["database"]
edition = "2018"

[features]
default = []
default = ["toml"]
rusqlite-bundled = ["refinery-core/rusqlite-bundled"]
rusqlite = ["refinery-core/rusqlite"]
postgres = ["refinery-core/postgres"]
Expand All @@ -22,6 +22,8 @@ tokio-postgres = ["refinery-core/tokio-postgres"]
mysql_async = ["refinery-core/mysql_async"]
tiberius = ["refinery-core/tiberius"]
tiberius-config = ["refinery-core/tiberius", "refinery-core/tiberius-config"]
serde = ["refinery-core/serde"]
toml = ["refinery-core/toml"]

[dependencies]
refinery-core = { version = "0.8.12", path = "../refinery_core" }
Expand Down
2 changes: 1 addition & 1 deletion refinery_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sqlite-bundled = ["sqlite", "refinery-core/rusqlite-bundled"]
mssql = ["refinery-core/tiberius-config", "tokio"]

[dependencies]
refinery-core = { version = "0.8.12", path = "../refinery_core", default-features = false }
refinery-core = { version = "0.8.12", path = "../refinery_core", default-features = false, features = ["toml"] }
clap = { version = "4", features = ["derive"] }
human-panic = "1.1.3"
toml = "0.8"
Expand Down
6 changes: 4 additions & 2 deletions refinery_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ tiberius = ["dep:tiberius", "futures", "tokio", "tokio/net"]
tiberius-config = ["tiberius", "tokio", "tokio-util"]
tokio-postgres = ["dep:tokio-postgres", "tokio", "tokio/rt"]
mysql_async = ["dep:mysql_async"]
serde = ["dep:serde"]
toml = ["serde", "dep:toml"]

[dependencies]
async-trait = "0.1"
cfg-if = "1.0"
log = "0.4"
regex = "1"
serde = { version = "1", features = ["derive"] }
siphasher = "1.0"
thiserror = "1"
toml = "0.8.8"
url = "2.0"
walkdir = "2.3.1"

Expand All @@ -39,6 +39,8 @@ tokio = { version = "1.0", optional = true }
futures = { version = "0.3.16", optional = true, features = ["async-await"] }
tokio-util = { version = "0.7.7", features = ["compat"], optional = true }
time = { version = "0.3.5", features = ["parsing", "formatting"] }
serde = { version = "1", features = ["derive"], optional = true }
toml = { version = "0.8.8", optional = true }

[dev-dependencies]
barrel = { git = "https://github.com/jxs/barrel", features = ["sqlite3", "pg", "mysql", "mssql"] }
Expand Down
11 changes: 7 additions & 4 deletions refinery_core/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::error::Kind;
use crate::Error;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::fs;
use std::path::{Path, PathBuf};
Expand All @@ -9,12 +8,14 @@ use url::Url;

// refinery config file used by migrate_from_config if migration from a Config struct is preferred instead of using the macros
// Config can either be instanced with [`Config::new`] or retrieved from a config file with [`Config::from_file_location`]
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Config {
main: Main,
}

#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Debug)]
#[derive(Clone, Copy, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ConfigDbType {
Mysql,
Postgres,
Expand Down Expand Up @@ -52,6 +53,7 @@ impl Config {
}

/// create a new Config instance from a config file located on the file system
#[cfg(feature = "toml")]
pub fn from_file_location<T: AsRef<Path>>(location: T) -> Result<Config, Error> {
let file = std::fs::read_to_string(&location).map_err(|err| {
Error::new(
Expand Down Expand Up @@ -259,7 +261,8 @@ impl FromStr for Config {
}
}

#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
struct Main {
db_type: ConfigDbType,
db_path: Option<PathBuf>,
Expand Down