1 parent
8782baa705
commit
a24e1efe31
12 files changed
+142
-142
No files matched your search
+7
-7
@@ -1,12 +1,12 @@
|
||||
//! Registry: local storage of built VM artifacts under
|
||||
//! `$XDG_DATA_HOME/slim-rs/registry/<image>/`.
|
||||
//! `$XDG_DATA_HOME/boco/registry/<image>/`.
|
||||
|
||||
use anyhow::{Context, Result, anyhow, bail};
|
||||
use std::{fs, io, path::PathBuf};
|
||||
|
||||
/// Validate a user-supplied image name before it is used in a registry path.
|
||||
///
|
||||
/// The name becomes a directory under `$XDG_DATA_HOME/slim-rs/registry/`, so
|
||||
/// The name becomes a directory under `$XDG_DATA_HOME/boco/registry/`, so
|
||||
/// path separators and `.`/`..` would allow escaping that directory.
|
||||
/// Allow-list: ASCII alphanumerics plus `.`, `_`, `:`, `-` (covers image
|
||||
/// refs like `alpine:3.15`).
|
||||
@@ -27,15 +27,15 @@ pub(crate) fn validate_image_name(name: &str) -> Result<()> {
|
||||
}
|
||||
|
||||
pub(crate) fn registry_base_dir() -> Result<PathBuf> {
|
||||
let base = xdg::BaseDirectories::with_prefix("slim-rs");
|
||||
let base = xdg::BaseDirectories::with_prefix("boco");
|
||||
base.create_data_directory("registry")
|
||||
.context("Failed to create XDG_DATA_HOME subdirectory")
|
||||
}
|
||||
|
||||
pub(crate) fn init_binary_path() -> Result<PathBuf> {
|
||||
let base = xdg::BaseDirectories::with_prefix("slim-rs");
|
||||
base.get_data_file("slim-init")
|
||||
.context("slim-init not found in XDG data dir")
|
||||
let base = xdg::BaseDirectories::with_prefix("boco");
|
||||
base.get_data_file("boco-init")
|
||||
.context("boco-init not found in XDG data dir")
|
||||
}
|
||||
|
||||
pub(crate) fn registry_dir(image: &str) -> Result<PathBuf> {
|
||||
@@ -62,7 +62,7 @@ mod tests {
|
||||
fn accepts_valid_image_names() {
|
||||
for name in [
|
||||
"alpine:3.15",
|
||||
"slim",
|
||||
"boco",
|
||||
"mock-vm",
|
||||
"my_vm",
|
||||
"a.b.c",
|
||||
|
||||
Reference in new issue
Block a user