Compare commits
No commits in common. "88e4a2a4b13d7e4897411e2e62225d83e133b927" and "fe7a676cac0097b51739fccf1e9cf6e6699e844e" have entirely different histories.
88e4a2a4b1
...
fe7a676cac
@ -1,6 +1,7 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::env;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -6,6 +6,7 @@ use redis::Cmd;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::redisclient;
|
use crate::redisclient;
|
||||||
|
use crate::git::git::parse_git_url;
|
||||||
|
|
||||||
// Define a custom error type for GitExecutor operations
|
// Define a custom error type for GitExecutor operations
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map};
|
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::virt::buildah::{BuildahError, Image, Builder, ContentOperations};
|
use crate::virt::buildah::{self, BuildahError, Image, Builder, ContentOperations};
|
||||||
use crate::process::CommandResult;
|
use crate::process::CommandResult;
|
||||||
|
|
||||||
/// Register Buildah module functions with the Rhai engine
|
/// Register Buildah module functions with the Rhai engine
|
||||||
|
@ -67,9 +67,6 @@ pub use crate::text::{
|
|||||||
dedent, prefix
|
dedent, prefix
|
||||||
};
|
};
|
||||||
|
|
||||||
// Re-export TextReplacer functions
|
|
||||||
pub use text::*;
|
|
||||||
|
|
||||||
// Rename copy functions to avoid conflicts
|
// Rename copy functions to avoid conflicts
|
||||||
pub use os::copy as os_copy;
|
pub use os::copy as os_copy;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
//! This module provides Rhai wrappers for the functions in the Nerdctl module.
|
//! This module provides Rhai wrappers for the functions in the Nerdctl module.
|
||||||
|
|
||||||
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map};
|
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map};
|
||||||
|
use std::collections::HashMap;
|
||||||
use crate::virt::nerdctl::{self, NerdctlError, Image, Container};
|
use crate::virt::nerdctl::{self, NerdctlError, Image, Container};
|
||||||
use crate::process::CommandResult;
|
use crate::process::CommandResult;
|
||||||
|
|
||||||
@ -50,52 +51,52 @@ pub fn container_from_image(name: &str, image: &str) -> Result<Container, Box<Ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Reset the container configuration to defaults while keeping the name and image
|
/// Reset the container configuration to defaults while keeping the name and image
|
||||||
pub fn container_reset(container: Container) -> Container {
|
pub fn container_reset(mut container: Container) -> Container {
|
||||||
container.reset()
|
container.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a port mapping to a Container
|
/// Add a port mapping to a Container
|
||||||
pub fn container_with_port(container: Container, port: &str) -> Container {
|
pub fn container_with_port(mut container: Container, port: &str) -> Container {
|
||||||
container.with_port(port)
|
container.with_port(port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a volume mount to a Container
|
/// Add a volume mount to a Container
|
||||||
pub fn container_with_volume(container: Container, volume: &str) -> Container {
|
pub fn container_with_volume(mut container: Container, volume: &str) -> Container {
|
||||||
container.with_volume(volume)
|
container.with_volume(volume)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add an environment variable to a Container
|
/// Add an environment variable to a Container
|
||||||
pub fn container_with_env(container: Container, key: &str, value: &str) -> Container {
|
pub fn container_with_env(mut container: Container, key: &str, value: &str) -> Container {
|
||||||
container.with_env(key, value)
|
container.with_env(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the network for a Container
|
/// Set the network for a Container
|
||||||
pub fn container_with_network(container: Container, network: &str) -> Container {
|
pub fn container_with_network(mut container: Container, network: &str) -> Container {
|
||||||
container.with_network(network)
|
container.with_network(network)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a network alias to a Container
|
/// Add a network alias to a Container
|
||||||
pub fn container_with_network_alias(container: Container, alias: &str) -> Container {
|
pub fn container_with_network_alias(mut container: Container, alias: &str) -> Container {
|
||||||
container.with_network_alias(alias)
|
container.with_network_alias(alias)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set CPU limit for a Container
|
/// Set CPU limit for a Container
|
||||||
pub fn container_with_cpu_limit(container: Container, cpus: &str) -> Container {
|
pub fn container_with_cpu_limit(mut container: Container, cpus: &str) -> Container {
|
||||||
container.with_cpu_limit(cpus)
|
container.with_cpu_limit(cpus)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set memory limit for a Container
|
/// Set memory limit for a Container
|
||||||
pub fn container_with_memory_limit(container: Container, memory: &str) -> Container {
|
pub fn container_with_memory_limit(mut container: Container, memory: &str) -> Container {
|
||||||
container.with_memory_limit(memory)
|
container.with_memory_limit(memory)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set restart policy for a Container
|
/// Set restart policy for a Container
|
||||||
pub fn container_with_restart_policy(container: Container, policy: &str) -> Container {
|
pub fn container_with_restart_policy(mut container: Container, policy: &str) -> Container {
|
||||||
container.with_restart_policy(policy)
|
container.with_restart_policy(policy)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set health check for a Container
|
/// Set health check for a Container
|
||||||
pub fn container_with_health_check(container: Container, cmd: &str) -> Container {
|
pub fn container_with_health_check(mut container: Container, cmd: &str) -> Container {
|
||||||
container.with_health_check(cmd)
|
container.with_health_check(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,18 +145,18 @@ pub fn container_with_network_aliases(mut container: Container, aliases: Array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set memory swap limit for a Container
|
/// Set memory swap limit for a Container
|
||||||
pub fn container_with_memory_swap_limit(container: Container, memory_swap: &str) -> Container {
|
pub fn container_with_memory_swap_limit(mut container: Container, memory_swap: &str) -> Container {
|
||||||
container.with_memory_swap_limit(memory_swap)
|
container.with_memory_swap_limit(memory_swap)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set CPU shares for a Container
|
/// Set CPU shares for a Container
|
||||||
pub fn container_with_cpu_shares(container: Container, shares: &str) -> Container {
|
pub fn container_with_cpu_shares(mut container: Container, shares: &str) -> Container {
|
||||||
container.with_cpu_shares(shares)
|
container.with_cpu_shares(shares)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set health check with options for a Container
|
/// Set health check with options for a Container
|
||||||
pub fn container_with_health_check_options(
|
pub fn container_with_health_check_options(
|
||||||
container: Container,
|
mut container: Container,
|
||||||
cmd: &str,
|
cmd: &str,
|
||||||
interval: Option<&str>,
|
interval: Option<&str>,
|
||||||
timeout: Option<&str>,
|
timeout: Option<&str>,
|
||||||
@ -168,12 +169,12 @@ pub fn container_with_health_check_options(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set snapshotter for a Container
|
/// Set snapshotter for a Container
|
||||||
pub fn container_with_snapshotter(container: Container, snapshotter: &str) -> Container {
|
pub fn container_with_snapshotter(mut container: Container, snapshotter: &str) -> Container {
|
||||||
container.with_snapshotter(snapshotter)
|
container.with_snapshotter(snapshotter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set detach mode for a Container
|
/// Set detach mode for a Container
|
||||||
pub fn container_with_detach(container: Container, detach: bool) -> Container {
|
pub fn container_with_detach(mut container: Container, detach: bool) -> Container {
|
||||||
container.with_detach(detach)
|
container.with_detach(detach)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! This module provides Rhai wrappers for the functions in the Text module.
|
//! This module provides Rhai wrappers for the functions in the Text module.
|
||||||
|
|
||||||
use rhai::{Engine, EvalAltResult, Array, Map, Position};
|
use rhai::{Engine, EvalAltResult, Array, Dynamic, Map, Position};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::text::{
|
use crate::text::{
|
||||||
TextReplacer, TextReplacerBuilder,
|
TextReplacer, TextReplacerBuilder,
|
||||||
@ -24,41 +24,39 @@ pub fn register_text_module(engine: &mut Engine) -> Result<(), Box<EvalAltResult
|
|||||||
// Register types
|
// Register types
|
||||||
register_text_types(engine)?;
|
register_text_types(engine)?;
|
||||||
|
|
||||||
// Register TextReplacer constructor
|
// Register TextReplacer functions
|
||||||
engine.register_fn("text_replacer_new", text_replacer_new);
|
engine.register_fn("text_replacer_new", text_replacer_new);
|
||||||
|
|
||||||
// Register TextReplacerBuilder instance methods
|
|
||||||
engine.register_fn("pattern", pattern);
|
|
||||||
engine.register_fn("replacement", replacement);
|
|
||||||
engine.register_fn("regex", regex);
|
|
||||||
engine.register_fn("case_insensitive", case_insensitive);
|
|
||||||
engine.register_fn("and", and);
|
|
||||||
engine.register_fn("build", build);
|
|
||||||
|
|
||||||
// Register TextReplacer instance methods
|
// Register TextReplacer instance methods
|
||||||
engine.register_fn("replace", replace);
|
engine.register_fn("pattern", builder_pattern);
|
||||||
engine.register_fn("replace_file", replace_file);
|
engine.register_fn("replacement", builder_replacement);
|
||||||
engine.register_fn("replace_file_in_place", replace_file_in_place);
|
engine.register_fn("regex", builder_regex);
|
||||||
engine.register_fn("replace_file_to", replace_file_to);
|
engine.register_fn("case_insensitive", builder_case_insensitive);
|
||||||
|
engine.register_fn("and", builder_and);
|
||||||
|
engine.register_fn("build", builder_build);
|
||||||
|
engine.register_fn("replace", replacer_replace);
|
||||||
|
engine.register_fn("replace_file", replacer_replace_file);
|
||||||
|
engine.register_fn("replace_file_in_place", replacer_replace_file_in_place);
|
||||||
|
engine.register_fn("replace_file_to", replacer_replace_file_to);
|
||||||
|
|
||||||
// Register TemplateBuilder constructor
|
// Register TemplateBuilder functions
|
||||||
engine.register_fn("template_builder_open", template_builder_open);
|
engine.register_fn("template_builder_open", template_builder_open);
|
||||||
|
|
||||||
// Register TemplateBuilder instance methods
|
// Register TemplateBuilder instance methods
|
||||||
engine.register_fn("add_var", add_var_string);
|
engine.register_fn("add_var", template_add_var_string);
|
||||||
engine.register_fn("add_var", add_var_int);
|
engine.register_fn("add_var", template_add_var_int);
|
||||||
engine.register_fn("add_var", add_var_float);
|
engine.register_fn("add_var", template_add_var_float);
|
||||||
engine.register_fn("add_var", add_var_bool);
|
engine.register_fn("add_var", template_add_var_bool);
|
||||||
engine.register_fn("add_var", add_var_array);
|
engine.register_fn("add_var", template_add_var_array);
|
||||||
engine.register_fn("add_vars", add_vars);
|
engine.register_fn("add_vars", template_add_vars);
|
||||||
engine.register_fn("render", render);
|
engine.register_fn("render", template_render);
|
||||||
engine.register_fn("render_to_file", render_to_file);
|
engine.register_fn("render_to_file", template_render_to_file);
|
||||||
|
|
||||||
// Register Fix functions directly from text module
|
// Register Fix functions
|
||||||
engine.register_fn("name_fix", crate::text::name_fix);
|
engine.register_fn("name_fix", crate::text::name_fix);
|
||||||
engine.register_fn("path_fix", crate::text::path_fix);
|
engine.register_fn("path_fix", crate::text::path_fix);
|
||||||
|
|
||||||
// Register Dedent functions directly from text module
|
// Register Dedent functions
|
||||||
engine.register_fn("dedent", crate::text::dedent);
|
engine.register_fn("dedent", crate::text::dedent);
|
||||||
engine.register_fn("prefix", crate::text::prefix);
|
engine.register_fn("prefix", crate::text::prefix);
|
||||||
|
|
||||||
@ -76,6 +74,10 @@ fn register_text_types(engine: &mut Engine) -> Result<(), Box<EvalAltResult>> {
|
|||||||
// Register TemplateBuilder type
|
// Register TemplateBuilder type
|
||||||
engine.register_type_with_name::<TemplateBuilder>("TemplateBuilder");
|
engine.register_type_with_name::<TemplateBuilder>("TemplateBuilder");
|
||||||
|
|
||||||
|
// Register getters for TextReplacer properties (if any)
|
||||||
|
|
||||||
|
// Register getters for TemplateBuilder properties (if any)
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,52 +117,52 @@ pub fn text_replacer_new() -> TextReplacerBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the pattern to search for
|
/// Sets the pattern to search for
|
||||||
pub fn pattern(builder: TextReplacerBuilder, pat: &str) -> TextReplacerBuilder {
|
pub fn builder_pattern(builder: TextReplacerBuilder, pat: &str) -> TextReplacerBuilder {
|
||||||
builder.pattern(pat)
|
builder.pattern(pat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the replacement text
|
/// Sets the replacement text
|
||||||
pub fn replacement(builder: TextReplacerBuilder, rep: &str) -> TextReplacerBuilder {
|
pub fn builder_replacement(builder: TextReplacerBuilder, rep: &str) -> TextReplacerBuilder {
|
||||||
builder.replacement(rep)
|
builder.replacement(rep)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether to use regex
|
/// Sets whether to use regex
|
||||||
pub fn regex(builder: TextReplacerBuilder, yes: bool) -> TextReplacerBuilder {
|
pub fn builder_regex(builder: TextReplacerBuilder, yes: bool) -> TextReplacerBuilder {
|
||||||
builder.regex(yes)
|
builder.regex(yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets whether the replacement should be case-insensitive
|
/// Sets whether the replacement should be case-insensitive
|
||||||
pub fn case_insensitive(builder: TextReplacerBuilder, yes: bool) -> TextReplacerBuilder {
|
pub fn builder_case_insensitive(builder: TextReplacerBuilder, yes: bool) -> TextReplacerBuilder {
|
||||||
builder.case_insensitive(yes)
|
builder.case_insensitive(yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds another replacement operation to the chain and resets the builder for a new operation
|
/// Adds another replacement operation to the chain and resets the builder for a new operation
|
||||||
pub fn and(builder: TextReplacerBuilder) -> TextReplacerBuilder {
|
pub fn builder_and(builder: TextReplacerBuilder) -> TextReplacerBuilder {
|
||||||
builder.and()
|
builder.and()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds the TextReplacer with all configured replacement operations
|
/// Builds the TextReplacer with all configured replacement operations
|
||||||
pub fn build(builder: TextReplacerBuilder) -> Result<TextReplacer, Box<EvalAltResult>> {
|
pub fn builder_build(builder: TextReplacerBuilder) -> Result<TextReplacer, Box<EvalAltResult>> {
|
||||||
string_error_to_rhai_error(builder.build())
|
string_error_to_rhai_error(builder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies all configured replacement operations to the input text
|
/// Applies all configured replacement operations to the input text
|
||||||
pub fn replace(replacer: &mut TextReplacer, input: &str) -> String {
|
pub fn replacer_replace(replacer: &mut TextReplacer, input: &str) -> String {
|
||||||
replacer.replace(input)
|
replacer.replace(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a file, applies all replacements, and returns the result as a string
|
/// Reads a file, applies all replacements, and returns the result as a string
|
||||||
pub fn replace_file(replacer: &mut TextReplacer, path: &str) -> Result<String, Box<EvalAltResult>> {
|
pub fn replacer_replace_file(replacer: &mut TextReplacer, path: &str) -> Result<String, Box<EvalAltResult>> {
|
||||||
io_error_to_rhai_error(replacer.replace_file(path))
|
io_error_to_rhai_error(replacer.replace_file(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a file, applies all replacements, and writes the result back to the file
|
/// Reads a file, applies all replacements, and writes the result back to the file
|
||||||
pub fn replace_file_in_place(replacer: &mut TextReplacer, path: &str) -> Result<(), Box<EvalAltResult>> {
|
pub fn replacer_replace_file_in_place(replacer: &mut TextReplacer, path: &str) -> Result<(), Box<EvalAltResult>> {
|
||||||
io_error_to_rhai_error(replacer.replace_file_in_place(path))
|
io_error_to_rhai_error(replacer.replace_file_in_place(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a file, applies all replacements, and writes the result to a new file
|
/// Reads a file, applies all replacements, and writes the result to a new file
|
||||||
pub fn replace_file_to(replacer: &mut TextReplacer, input_path: &str, output_path: &str) -> Result<(), Box<EvalAltResult>> {
|
pub fn replacer_replace_file_to(replacer: &mut TextReplacer, input_path: &str, output_path: &str) -> Result<(), Box<EvalAltResult>> {
|
||||||
io_error_to_rhai_error(replacer.replace_file_to(input_path, output_path))
|
io_error_to_rhai_error(replacer.replace_file_to(input_path, output_path))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,29 +174,29 @@ pub fn template_builder_open(template_path: &str) -> Result<TemplateBuilder, Box
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a string variable to the template context
|
/// Adds a string variable to the template context
|
||||||
pub fn add_var_string(builder: TemplateBuilder, name: &str, value: &str) -> TemplateBuilder {
|
pub fn template_add_var_string(builder: TemplateBuilder, name: &str, value: &str) -> TemplateBuilder {
|
||||||
builder.add_var(name, value)
|
builder.add_var(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an integer variable to the template context
|
/// Adds an integer variable to the template context
|
||||||
pub fn add_var_int(builder: TemplateBuilder, name: &str, value: i64) -> TemplateBuilder {
|
pub fn template_add_var_int(builder: TemplateBuilder, name: &str, value: i64) -> TemplateBuilder {
|
||||||
builder.add_var(name, value)
|
builder.add_var(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a float variable to the template context
|
/// Adds a float variable to the template context
|
||||||
pub fn add_var_float(builder: TemplateBuilder, name: &str, value: f64) -> TemplateBuilder {
|
pub fn template_add_var_float(builder: TemplateBuilder, name: &str, value: f64) -> TemplateBuilder {
|
||||||
builder.add_var(name, value)
|
builder.add_var(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a boolean variable to the template context
|
/// Adds a boolean variable to the template context
|
||||||
pub fn add_var_bool(builder: TemplateBuilder, name: &str, value: bool) -> TemplateBuilder {
|
pub fn template_add_var_bool(builder: TemplateBuilder, name: &str, value: bool) -> TemplateBuilder {
|
||||||
builder.add_var(name, value)
|
builder.add_var(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an array variable to the template context
|
/// Adds an array variable to the template context
|
||||||
pub fn add_var_array(builder: TemplateBuilder, name: &str, array: Array) -> TemplateBuilder {
|
pub fn template_add_var_array(builder: TemplateBuilder, name: &str, value: Array) -> TemplateBuilder {
|
||||||
// Convert Rhai Array to Vec<String>
|
// Convert Rhai Array to Vec<String>
|
||||||
let vec: Vec<String> = array.iter()
|
let vec: Vec<String> = value.iter()
|
||||||
.filter_map(|v| v.clone().into_string().ok())
|
.filter_map(|v| v.clone().into_string().ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@ -202,7 +204,7 @@ pub fn add_var_array(builder: TemplateBuilder, name: &str, array: Array) -> Temp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Adds multiple variables to the template context from a Map
|
/// Adds multiple variables to the template context from a Map
|
||||||
pub fn add_vars(builder: TemplateBuilder, vars: Map) -> TemplateBuilder {
|
pub fn template_add_vars(builder: TemplateBuilder, vars: Map) -> TemplateBuilder {
|
||||||
// Convert Rhai Map to Rust HashMap
|
// Convert Rhai Map to Rust HashMap
|
||||||
let mut hash_map = HashMap::new();
|
let mut hash_map = HashMap::new();
|
||||||
|
|
||||||
@ -217,11 +219,11 @@ pub fn add_vars(builder: TemplateBuilder, vars: Map) -> TemplateBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Renders the template with the current context
|
/// Renders the template with the current context
|
||||||
pub fn render(builder: &mut TemplateBuilder) -> Result<String, Box<EvalAltResult>> {
|
pub fn template_render(builder: &mut TemplateBuilder) -> Result<String, Box<EvalAltResult>> {
|
||||||
tera_error_to_rhai_error(builder.render())
|
tera_error_to_rhai_error(builder.render())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Renders the template and writes the result to a file
|
/// Renders the template and writes the result to a file
|
||||||
pub fn render_to_file(builder: &mut TemplateBuilder, output_path: &str) -> Result<(), Box<EvalAltResult>> {
|
pub fn template_render_to_file(builder: &mut TemplateBuilder, output_path: &str) -> Result<(), Box<EvalAltResult>> {
|
||||||
io_error_to_rhai_error(builder.render_to_file(output_path))
|
io_error_to_rhai_error(builder.render_to_file(output_path))
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ println("===== TextReplacer Examples =====");
|
|||||||
|
|
||||||
// Create a temporary file for testing
|
// Create a temporary file for testing
|
||||||
let temp_file = "text_replacer_test.txt";
|
let temp_file = "text_replacer_test.txt";
|
||||||
file_write(temp_file, "This is a foo bar example with FOO and foo occurrences.\nAnother line with foo and bar.");
|
write_file(temp_file, "This is a foo bar example with FOO and foo occurrences.\nAnother line with foo and bar.");
|
||||||
|
|
||||||
// Example 1: Simple replacement
|
// Example 1: Simple replacement
|
||||||
println("\n--- Example 1: Simple replacement ---");
|
println("\n--- Example 1: Simple replacement ---");
|
||||||
@ -68,7 +68,7 @@ println("\n\n===== TemplateBuilder Examples =====");
|
|||||||
|
|
||||||
// Create a temporary template file
|
// Create a temporary template file
|
||||||
let template_file = "template_test.txt";
|
let template_file = "template_test.txt";
|
||||||
file_write(template_file, "Hello, {{ name }}! Welcome to {{ place }}.\n{% if show_greeting %}Glad to have you here!{% endif %}\nYour items:\n{% for item in items %} - {{ item }}{% if not loop.last %}\n{% endif %}{% endfor %}\n");
|
write_file(template_file, "Hello, {{ name }}! Welcome to {{ place }}.\n{% if show_greeting %}Glad to have you here!{% endif %}\nYour items:\n{% for item in items %} - {{ item }}{% if not loop.last %}\n{% endif %}{% endfor %}\n");
|
||||||
|
|
||||||
// Example 1: Simple template rendering
|
// Example 1: Simple template rendering
|
||||||
println("\n--- Example 1: Simple template rendering ---");
|
println("\n--- Example 1: Simple template rendering ---");
|
||||||
@ -108,7 +108,7 @@ let template = template_builder_open(template_file)
|
|||||||
|
|
||||||
template.render_to_file(output_file);
|
template.render_to_file(output_file);
|
||||||
println(`Template rendered to file: ${output_file}`);
|
println(`Template rendered to file: ${output_file}`);
|
||||||
println(`Content of the rendered file:\n${file_read(output_file)}`);
|
println(`Content of the rendered file:\n${read_file(output_file)}`);
|
||||||
|
|
||||||
// Clean up temporary files
|
// Clean up temporary files
|
||||||
delete(template_file);
|
delete(template_file);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read, Seek, SeekFrom};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
/// Represents the type of replacement to perform.
|
/// Represents the type of replacement to perform.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Basic buildah operations for container management
|
// Basic buildah operations for container management
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use crate::process::CommandResult;
|
use crate::process::CommandResult;
|
||||||
use super::BuildahError;
|
use super::{BuildahError, Builder};
|
||||||
|
|
||||||
|
|
||||||
/// Execute a buildah command and return the result
|
/// Execute a buildah command and return the result
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// File: /root/code/git.ourworld.tf/herocode/sal/src/virt/nerdctl/container.rs
|
// File: /root/code/git.ourworld.tf/herocode/sal/src/virt/nerdctl/container.rs
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use crate::process::CommandResult;
|
||||||
use crate::virt::nerdctl::{execute_nerdctl_command, NerdctlError};
|
use crate::virt::nerdctl::{execute_nerdctl_command, NerdctlError};
|
||||||
use crate::os;
|
use crate::os;
|
||||||
use super::container_types::Container;
|
use super::container_types::{Container, HealthCheck, ContainerStatus, ResourceUsage};
|
||||||
|
|
||||||
impl Container {
|
impl Container {
|
||||||
/// Create a new container reference with the given name
|
/// Create a new container reference with the given name
|
||||||
|
@ -12,7 +12,7 @@ impl Container {
|
|||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
/// * `Self` - The container instance for method chaining
|
/// * `Self` - The container instance for method chaining
|
||||||
pub fn reset(self) -> Self {
|
pub fn reset(mut self) -> Self {
|
||||||
let name = self.name;
|
let name = self.name;
|
||||||
let image = self.image.clone();
|
let image = self.image.clone();
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// File: /root/code/git.ourworld.tf/herocode/sal/src/virt/nerdctl/images.rs
|
// File: /root/code/git.ourworld.tf/herocode/sal/src/virt/nerdctl/images.rs
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
use crate::virt::nerdctl::execute_nerdctl_command;
|
use crate::virt::nerdctl::execute_nerdctl_command;
|
||||||
use crate::process::CommandResult;
|
use crate::process::CommandResult;
|
||||||
use super::NerdctlError;
|
use super::NerdctlError;
|
||||||
use serde_json::{self};
|
use serde_json::{self, Value};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents a container image
|
/// Represents a container image
|
||||||
|
Loading…
Reference in New Issue
Block a user