...
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
// Basic buildah operations for container management
|
||||
use std::process::Command;
|
||||
use crate::process::CommandResult;
|
||||
use super::BuildahError;
|
||||
|
||||
|
||||
/// Execute a buildah command and return the result
|
||||
pub fn execute_buildah_command(args: &[&str]) -> Dynamic {
|
||||
pub fn execute_buildah_command(args: &[&str]) -> Result<CommandResult, BuildahError> {
|
||||
let output = Command::new("buildah")
|
||||
.args(args)
|
||||
.output();
|
||||
@@ -20,10 +22,15 @@ pub fn execute_buildah_command(args: &[&str]) -> Dynamic {
|
||||
code: output.status.code().unwrap_or(-1),
|
||||
};
|
||||
|
||||
result.to_dynamic()
|
||||
if result.success {
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(BuildahError::CommandFailed(format!("Command failed with code {}: {}",
|
||||
result.code, result.stderr.trim())))
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
CommandResult::error(&format!("Failed to execute buildah command: {}", e)).to_dynamic()
|
||||
Err(BuildahError::CommandExecutionFailed(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user