From 3f461334ecc7985e1db4da183fe6a83975651860 Mon Sep 17 00:00:00 2001 From: Maxime Van Hees Date: Wed, 2 Apr 2025 14:41:50 +0200 Subject: [PATCH] added example --- .../buildah/example.rs => examples/buildah.rs | 10 ++++++--- src/git/git.rs | 2 +- src/git/git_executor.rs | 11 ---------- src/process/run.rs | 22 ++++++++----------- src/redisclient/redisclient.rs | 2 +- src/virt/buildah/images.rs | 1 - src/virt/buildah/mod.rs | 4 +--- 7 files changed, 19 insertions(+), 33 deletions(-) rename src/virt/buildah/example.rs => examples/buildah.rs (96%) diff --git a/src/virt/buildah/example.rs b/examples/buildah.rs similarity index 96% rename from src/virt/buildah/example.rs rename to examples/buildah.rs index e00b414..f26fb39 100644 --- a/src/virt/buildah/example.rs +++ b/examples/buildah.rs @@ -4,7 +4,7 @@ //! common container operations like creating containers, running commands, //! and managing images. -use crate::virt::buildah::{self, BuildahError}; +use sal::virt::buildah::{self, BuildahError}; use std::collections::HashMap; /// Run a complete buildah workflow example @@ -114,12 +114,16 @@ pub fn run_all_examples() -> Result<(), BuildahError> { // Uncomment these to run the examples run_buildah_example()?; - build_image_example()?; - registry_operations_example()?; + // build_image_example()?; + // registry_operations_example()?; println!("\nTo run these examples, uncomment the function calls in run_all_examples()"); println!("Note that these examples require buildah to be installed on your system"); println!("and may require root/sudo privileges depending on your setup."); Ok(()) +} + +fn main() { + run_all_examples(); } \ No newline at end of file diff --git a/src/git/git.rs b/src/git/git.rs index c001a3b..7f0afca 100644 --- a/src/git/git.rs +++ b/src/git/git.rs @@ -80,7 +80,7 @@ impl Error for GitError { */ pub fn git_clone(url: &str) -> Result { // Check if git is installed - let git_check = Command::new("git") + let _git_check = Command::new("git") .arg("--version") .output() .map_err(GitError::GitNotInstalled)?; diff --git a/src/git/git_executor.rs b/src/git/git_executor.rs index 27f4ee5..197426b 100644 --- a/src/git/git_executor.rs +++ b/src/git/git_executor.rs @@ -293,17 +293,6 @@ impl GitExecutor { // Execute git command with username/password fn execute_with_credentials(&self, args: &[&str], username: &str, password: &str) -> Result { - // Helper method to execute a command and handle the result - fn execute_command(command: &mut Command) -> Result { - let output = command.output()?; - - if output.status.success() { - Ok(output) - } else { - let error = String::from_utf8_lossy(&output.stderr); - Err(GitExecutorError::GitCommandFailed(error.to_string())) - } - } // For HTTPS authentication, we need to modify the URL to include credentials // Create a new vector to hold our modified arguments let modified_args: Vec = args.iter().map(|&arg| { diff --git a/src/process/run.rs b/src/process/run.rs index f7e3cc8..49018ab 100644 --- a/src/process/run.rs +++ b/src/process/run.rs @@ -76,7 +76,7 @@ pub struct CommandResult { impl CommandResult { /// Create a default failed result with an error message - fn error(message: &str) -> Self { + fn _error(message: &str) -> Self { Self { stdout: String::new(), stderr: message.to_string(), @@ -132,10 +132,6 @@ fn handle_child_output(mut child: Child, silent: bool) -> Result Result