...
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map};
|
||||
use std::collections::HashMap;
|
||||
use crate::virt::buildah::{self, BuildahError, Image, Builder};
|
||||
use crate::virt::buildah::{self, BuildahError, Image, Builder, ContentOperations};
|
||||
use crate::process::CommandResult;
|
||||
|
||||
/// Register Buildah module functions with the Rhai engine
|
||||
@@ -150,12 +150,26 @@ pub fn builder_config(builder: &mut Builder, options: Map) -> Result<CommandResu
|
||||
|
||||
/// Write content to a file in the container
|
||||
pub fn builder_write_content(builder: &mut Builder, content: &str, dest_path: &str) -> Result<CommandResult, Box<EvalAltResult>> {
|
||||
bah_error_to_rhai_error(builder.write_content(content, dest_path))
|
||||
if let Some(container_id) = builder.container_id() {
|
||||
bah_error_to_rhai_error(ContentOperations::write_content(container_id, content, dest_path))
|
||||
} else {
|
||||
Err(Box::new(EvalAltResult::ErrorRuntime(
|
||||
"No container ID available".into(),
|
||||
rhai::Position::NONE
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Read content from a file in the container
|
||||
pub fn builder_read_content(builder: &mut Builder, source_path: &str) -> Result<String, Box<EvalAltResult>> {
|
||||
bah_error_to_rhai_error(builder.read_content(source_path))
|
||||
if let Some(container_id) = builder.container_id() {
|
||||
bah_error_to_rhai_error(ContentOperations::read_content(container_id, source_path))
|
||||
} else {
|
||||
Err(Box::new(EvalAltResult::ErrorRuntime(
|
||||
"No container ID available".into(),
|
||||
rhai::Position::NONE
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
// Builder static methods
|
||||
|
Reference in New Issue
Block a user