From 4dda49579dd5ae9e4fb30d0db576de051af5c410 Mon Sep 17 00:00:00 2001
From: Eduardo Trujillo <ed@chromabits.com>
Date: Tue, 15 Nov 2022 13:46:30 -0800
Subject: [PATCH] refactor(config): Remove unused functions

---
 src/config.rs | 64 +++++----------------------------------------------
 1 file changed, 6 insertions(+), 58 deletions(-)

diff --git a/src/config.rs b/src/config.rs
index bd98938..0898feb 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -273,71 +273,19 @@ impl From<IndexStrategyConfig> for IndexStrategy {
   }
 }
 
-/// Attempts to read a Config object from the specified path.
-///
-/// The configuration file is expected to be a TOML file.
-pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Config> {
-  let path = path.as_ref();
-
-  log::info!("Reading config file from {}", path.display());
-
-  let contents = fs::read_to_string(path).context(OpenConfig { path })?;
-
-  let config = toml::from_str(&contents);
-
-  config.context(DeserializeConfig { path })
-}
-
-/// Attempts to read a Config object from the specified paths.
-pub fn from_paths<P: AsRef<Path>>(paths: Vec<P>) -> Result<Config> {
-  for path in paths {
-    if path.as_ref().exists() {
-      return from_file(path);
-    }
-  }
-
-  Err(Error::NoValidPath)
-}
-
-/// Attempts to read a Config object from the current directory.
-///
-/// The configuration file is expected to be a TOML file named `config.toml`.
-pub fn from_current_dir() -> Result<Config> {
-  let mut current_path = env::current_dir().context(GetCurrentDir)?;
-
-  current_path.push("config.toml");
-
-  from_file(&current_path)
-}
-
-/// Similar to `from_paths`. Uses a default set of paths:
-///
-/// - `CURRENT_WORKING_DIRECTORY/config.toml`
-/// - `/etc/CRATE/config.toml`
-pub fn from_default_paths() -> Result<Config> {
-  let mut current_path = env::current_dir().context(GetCurrentDir)?;
-
-  current_path.push("config.toml");
-
-  let mut config_path = PathBuf::from("/etc/");
-
-  config_path.push(PKG_NAME);
-  config_path.push("config.toml");
-
-  let paths = vec![current_path, config_path];
-
-  from_paths(paths)
-}
-
 #[cfg(test)]
 mod tests {
-  use super::{from_file, BundleConfig, Config, ServerConfig, StatsConfig, UnbundlerConfig};
+  use collective::config::from_file;
+
+  use super::{BundleConfig, Config, ServerConfig, StatsConfig, UnbundlerConfig};
   use std::path::{Path, PathBuf};
 
   #[test]
   fn test_from_file() {
+    let config: Config = from_file(&Path::new("config.sample.toml"), None).unwrap();
+
     assert_eq!(
-      from_file(&Path::new("config.sample.toml")).unwrap(),
+      config,
       Config {
         stats: Some(StatsConfig {
           address: "127.0.0.1:8089".parse().unwrap(),
-- 
GitLab