| Crates.io | sal-virt |
| lib.rs | sal-virt |
| version | 0.1.0 |
| created_at | 2025-07-01 05:53:41.333565+00 |
| updated_at | 2025-07-01 05:53:41.333565+00 |
| description | SAL Virt - Virtualization and containerization tools including Buildah, Nerdctl, and RFS |
| homepage | |
| repository | https://git.threefold.info/herocode/sal |
| max_upload_size | |
| id | 1732805 |
| size | 787,307 |
sal-virt)The sal-virt package provides comprehensive virtualization and containerization tools for building, managing, and deploying containers and filesystem layers.
Add this to your Cargo.toml:
[dependencies]
sal-virt = "0.1.0"
Container image building with Buildah, providing:
Container management with Nerdctl, providing:
Remote filesystem operations, providing:
use sal_virt::buildah::Builder;
// Create a new builder
let mut builder = Builder::new("my-container", "alpine:latest")?;
// Configure the builder
builder.set_debug(true);
// Add content and run commands
builder.copy("./app", "/usr/local/bin/app")?;
builder.run(&["chmod", "+x", "/usr/local/bin/app"])?;
// Commit the image
let image_id = builder.commit("my-app:latest")?;
use sal_virt::nerdctl::Container;
// Create a container from an image
let container = Container::from_image("web-app", "nginx:alpine")?
.with_port("8080:80")
.with_volume("/host/data:/app/data")
.with_env("ENV_VAR", "production")
.with_restart_policy("always");
// Run the container
let result = container.run()?;
use sal_virt::rfs::{RfsBuilder, MountType, StoreSpec};
// Mount a remote filesystem
let mount = RfsBuilder::new("user@host:/remote/path", "/local/mount", MountType::SSH)
.with_option("read_only", "true")
.mount()?;
// Pack a directory
let specs = vec![StoreSpec::new("file").with_option("path", "/tmp/store")];
let pack_result = pack_directory("/source/dir", "/output/pack.rfs", &specs)?;
All functionality is available in Rhai scripts:
// Buildah in Rhai
let builder = bah_new("my-container", "alpine:latest");
builder.copy("./app", "/usr/local/bin/app");
builder.run(["chmod", "+x", "/usr/local/bin/app"]);
// Nerdctl in Rhai
let container = nerdctl_container_from_image("web-app", "nginx:alpine")
.with_port("8080:80")
.with_env("ENV", "production");
container.run();
// RFS in Rhai
let mount_options = #{ "read_only": "true" };
rfs_mount("user@host:/remote", "/local/mount", "ssh", mount_options);
sal-process: For command executionsal-os: For filesystem operationsanyhow: For error handlingserde: For serializationrhai: For scripting integrationThe package includes comprehensive tests:
# Run all tests
cargo test
# Run specific test suites
cargo test buildah_tests
cargo test nerdctl_tests
cargo test rfs_tests
# Run Rhai integration tests
cargo test --test rhai_integration
Each module provides its own error types:
BuildahError: For Buildah operationsNerdctlError: For Nerdctl operationsRfsError: For RFS operationsAll errors implement std::error::Error and provide detailed error messages.
Most operations can be configured through environment variables:
BUILDAH_DEBUG: Enable debug mode for BuildahNERDCTL_DEBUG: Enable debug mode for NerdctlRFS_DEBUG: Enable debug mode for RFSApache-2.0