Skip to content

Commit

Permalink
dont's save cloned git repos directly in home dir
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Jun 28, 2022
1 parent 5c42f13 commit e8d5989
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ a release.
Uncomment any of the following sections when they become relevant.
-->

There are no user-facing changes in this release.
Instead, some internal handling was changed to be more precise.

<!--
## Notable Changes
Below are some of the most relevant changes that are introduced with this release.
Expand Down
15 changes: 10 additions & 5 deletions src/k8s_types/pass_source.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Context};
use blake2::digest::{Update, VariableOutput};
use blake2::Blake2bVar;
use directories::UserDirs;
use directories::ProjectDirs;
use git2::build::{CheckoutBuilder, RepoBuilder};
use git2::{BranchType, Config, Cred, FetchOptions, RemoteCallbacks, Repository};
use okapi::schemars::JsonSchema;
Expand Down Expand Up @@ -59,12 +59,17 @@ impl GitPassSource {
.context("Could not finalize digest for constructing a unique password source path")?;

// append hex-encoded digest to '~/.password-store-'
let unique_path = ".password-store-".to_owned() + &hex::encode(digest);
let unique_path = UserDirs::new()
.context("Could not retrieve user directories")?
.home_dir()
let unique_path = "password-store-".to_owned() + &hex::encode(digest);
let unique_path = ProjectDirs::from("de", "ftsell", "kustomize-pass")
.context("Could not retrieve project directories")?
.data_local_dir()
.join(unique_path);

log::trace!(
"Computed unique path for repo {} is {}",
self.url,
unique_path.display()
);
Ok(unique_path)
}

Expand Down

0 comments on commit e8d5989

Please sign in to comment.