From 32d5f8c5177f25b94c2d9d81e2c66859d993fc9a Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:40:06 +0100 Subject: [PATCH] feat(registry): add DATA_DIR variable --- docs/src/content/docs/guides/self-hosting-registries.mdx | 4 ++++ registry/.env.example | 6 ++++-- registry/src/main.rs | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/src/content/docs/guides/self-hosting-registries.mdx b/docs/src/content/docs/guides/self-hosting-registries.mdx index 7c92a06..c856d4d 100644 --- a/docs/src/content/docs/guides/self-hosting-registries.mdx +++ b/docs/src/content/docs/guides/self-hosting-registries.mdx @@ -113,6 +113,10 @@ for this purpose. index repository.\ Example: `pesde@localhost` +- **DATA_DIR**: The directory where the registry stores miscellaneous data. + This value can use `{CWD}` to refer to the current working directory.\ + Default: `{CWD}/data` + - **ADDRESS**: The address to bind the server to.\ Default: `127.0.0.1` diff --git a/registry/.env.example b/registry/.env.example index f4600d1..8c9c0e2 100644 --- a/registry/.env.example +++ b/registry/.env.example @@ -1,11 +1,13 @@ INDEX_REPO_URL = # url of the index repository -GIT_USERNAME= # username of a Git account with push access to the index repository -GIT_PASSWORD= # password of the account (PAT for GitHub) +GIT_USERNAME= # username of a Git account with push access to the index repository +GIT_PASSWORD= # password of the account (PAT for GitHub) COMMITTER_GIT_NAME= # name of the committer used for index updates COMMITTER_GIT_EMAIL= # email of the committer used for index updates +DATA_DIR= # directory where miscellaneous data is stored + # AUTHENTICATION CONFIGURATION # Set the variables of the authentication you want to use in order to enable it diff --git a/registry/src/main.rs b/registry/src/main.rs index faca878..8ce2f67 100644 --- a/registry/src/main.rs +++ b/registry/src/main.rs @@ -85,7 +85,7 @@ async fn run() -> std::io::Result<()> { let port: u16 = benv!(parse "PORT" => "8080"); let cwd = current_dir().unwrap(); - let data_dir = cwd.join("data"); + let data_dir = PathBuf::from(benv!("DATA_DIR" => "{CWD}/data").replace("{CWD}", cwd.to_str().unwrap())); fs_err::create_dir_all(&data_dir).unwrap(); let project = Project::new(