Skip to content

Commit

Permalink
chore(vdev): Drop dependency on cached crate (vectordotdev#19693)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceg authored and AndrooTheChen committed Sep 23, 2024
1 parent 10169d9 commit 5b03813
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 81 deletions.
69 changes: 0 additions & 69 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vdev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ publish = false

[dependencies]
anyhow = "1.0.79"
cached = "0.48.0"
chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] }
clap.workspace = true
clap-verbosity-flag = "2.1.2"
Expand Down
19 changes: 9 additions & 10 deletions vdev/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cached::proc_macro::once;
use directories::ProjectDirs;

use std::env::consts::ARCH;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;

pub fn canonicalize_path(path: impl AsRef<Path>) -> String {
let path = path.as_ref();
Expand All @@ -12,12 +12,16 @@ pub fn canonicalize_path(path: impl AsRef<Path>) -> String {
.to_string()
}

#[once]
pub fn data_dir() -> PathBuf {
_project_dirs().data_local_dir().to_path_buf()
pub fn data_dir() -> &'static Path {
static DATA_DIR: OnceLock<PathBuf> = OnceLock::new();
DATA_DIR.get_or_init(|| {
ProjectDirs::from("", "vector", "vdev")
.expect("Could not determine the project directory")
.data_local_dir()
.to_path_buf()
})
}

#[once]
pub fn default_target() -> String {
if cfg!(windows) {
format!("{ARCH}-pc-windows-msvc")
Expand All @@ -35,8 +39,3 @@ pub fn default_features() -> &'static str {
"default"
}
}

#[once]
fn _project_dirs() -> ProjectDirs {
ProjectDirs::from("", "vector", "vdev").expect("Could not determine the project directory")
}
2 changes: 1 addition & 1 deletion vdev/src/testing/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::config::Environment;
use crate::{platform, util};

static DATA_DIR: Lazy<PathBuf> = Lazy::new(|| {
[platform::data_dir().as_path(), Path::new("integration")]
[platform::data_dir(), Path::new("integration")]
.into_iter()
.collect()
});
Expand Down

0 comments on commit 5b03813

Please sign in to comment.