added test for everything container related

This commit is contained in:
2025-04-02 16:12:31 +02:00
parent 5f6420a421
commit d6b53a72bb
8 changed files with 206 additions and 58 deletions

View File

@@ -52,3 +52,33 @@ pub fn remove(container: &str) -> Result<CommandResult, BuildahError> {
pub fn list() -> Result<CommandResult, BuildahError> {
execute_buildah_command(&["containers"])
}
/// Build an image from a Containerfile/Dockerfile
///
/// # Arguments
///
/// * `tag` - Optional tag for the image (e.g., "my-app:latest")
/// * `context_dir` - The directory containing the Containerfile/Dockerfile (usually ".")
/// * `file` - Optional path to a specific Containerfile/Dockerfile
/// * `isolation` - Optional isolation method (e.g., "chroot", "rootless", "oci")
pub fn build(tag: Option<&str>, context_dir: &str, file: &str, isolation: Option<&str>) -> Result<CommandResult, BuildahError> {
let mut args = Vec::new();
args.push("build");
if let Some(tag_value) = tag {
args.push("-t");
args.push(tag_value);
}
if let Some(isolation_value) = isolation {
args.push("--isolation");
args.push(isolation_value);
}
args.push("-f");
args.push(file);
args.push(context_dir);
execute_buildah_command(&args)
}