Skip to main content

kopiur_kopia/
env.rs

1//! The environment variables kopia itself reads, named once so every caller
2//! (the controller's in-process [`crate::KopiaClient`] and the mover `Job` the
3//! controller stamps) points at the same writable cache/log/config location.
4//!
5//! kopia defaults its cache, logs, and config under `$HOME` (`~/.cache/kopia`,
6//! `~/.config/kopia/repository.config`). On a distroless `nonroot` image `$HOME`
7//! is `/nonexistent`, and the operator runs with a read-only root filesystem, so
8//! those defaults are unwritable and every invocation errors with
9//! `mkdir /nonexistent: read-only file system`. We redirect all three onto a
10//! writable `emptyDir` mounted at [`DEFAULT_CACHE_DIR`].
11//!
12//! ```
13//! use kopiur_kopia::env;
14//!
15//! assert_eq!(env::CACHE_DIRECTORY_ENV, "KOPIA_CACHE_DIRECTORY");
16//! assert_eq!(env::LOG_DIR_ENV, "KOPIA_LOG_DIR");
17//! assert_eq!(env::CONFIG_PATH_ENV, "KOPIA_CONFIG_PATH");
18//! assert_eq!(env::DEFAULT_CACHE_DIR, "/var/cache/kopia");
19//! ```
20
21/// kopia's content/metadata cache directory. Content-addressed, so it is safe to
22/// share across concurrent invocations.
23pub const CACHE_DIRECTORY_ENV: &str = "KOPIA_CACHE_DIRECTORY";
24
25/// Directory kopia writes its CLI/content log files into.
26pub const LOG_DIR_ENV: &str = "KOPIA_LOG_DIR";
27
28/// Path to kopia's connection config file (the persisted repository binding).
29/// Unlike the cache, this is per-connection state: concurrent connects to
30/// *different* repositories must not share one file, or they clobber each other.
31pub const CONFIG_PATH_ENV: &str = "KOPIA_CONFIG_PATH";
32
33/// The writable base directory both the controller `Deployment` and the mover
34/// `Job` mount an `emptyDir` at, and that the binaries default their kopia
35/// cache/log/config under. Keep this in sync with the `kopia-cache` volume mount
36/// in `deploy/helm/kopiur/templates/deployment.yaml` and in
37/// `kopiur_mover::jobs::build_job`.
38pub const DEFAULT_CACHE_DIR: &str = "/var/cache/kopia";