This commit is contained in:
despiegk 2025-04-05 11:05:24 +02:00
parent 749c60e131
commit 8605e08a65
10 changed files with 21 additions and 27 deletions

View File

@ -1,7 +1,6 @@
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;

View File

@ -6,7 +6,6 @@ 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)]

View File

@ -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::{self, BuildahError, Image, Builder, ContentOperations}; use crate::virt::buildah::{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

View File

@ -3,7 +3,6 @@
//! 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;
@ -51,52 +50,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(mut container: Container) -> Container { pub fn container_reset(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(mut container: Container, port: &str) -> Container { pub fn container_with_port(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(mut container: Container, volume: &str) -> Container { pub fn container_with_volume(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(mut container: Container, key: &str, value: &str) -> Container { pub fn container_with_env(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(mut container: Container, network: &str) -> Container { pub fn container_with_network(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(mut container: Container, alias: &str) -> Container { pub fn container_with_network_alias(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(mut container: Container, cpus: &str) -> Container { pub fn container_with_cpu_limit(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(mut container: Container, memory: &str) -> Container { pub fn container_with_memory_limit(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(mut container: Container, policy: &str) -> Container { pub fn container_with_restart_policy(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(mut container: Container, cmd: &str) -> Container { pub fn container_with_health_check(container: Container, cmd: &str) -> Container {
container.with_health_check(cmd) container.with_health_check(cmd)
} }
@ -145,18 +144,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(mut container: Container, memory_swap: &str) -> Container { pub fn container_with_memory_swap_limit(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(mut container: Container, shares: &str) -> Container { pub fn container_with_cpu_shares(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(
mut container: Container, container: Container,
cmd: &str, cmd: &str,
interval: Option<&str>, interval: Option<&str>,
timeout: Option<&str>, timeout: Option<&str>,
@ -169,12 +168,12 @@ pub fn container_with_health_check_options(
} }
/// Set snapshotter for a Container /// Set snapshotter for a Container
pub fn container_with_snapshotter(mut container: Container, snapshotter: &str) -> Container { pub fn container_with_snapshotter(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(mut container: Container, detach: bool) -> Container { pub fn container_with_detach(container: Container, detach: bool) -> Container {
container.with_detach(detach) container.with_detach(detach)
} }

View File

@ -4,7 +4,6 @@
use rhai::{Engine, EvalAltResult, Array, Map, Position}; use rhai::{Engine, EvalAltResult, Array, Map, Position};
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path;
use crate::text::{ use crate::text::{
TextReplacer, TextReplacerBuilder, TextReplacer, TextReplacerBuilder,
TemplateBuilder, TemplateBuilder,

View File

@ -1,6 +1,6 @@
use regex::Regex; use regex::Regex;
use std::fs; use std::fs;
use std::io::{self, Read, Seek, SeekFrom}; use std::io::{self, Read};
use std::path::Path; use std::path::Path;
/// Represents the type of replacement to perform. /// Represents the type of replacement to perform.

View File

@ -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, Builder}; use super::BuildahError;
/// Execute a buildah command and return the result /// Execute a buildah command and return the result

View File

@ -1,10 +1,9 @@
// 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, HealthCheck, ContainerStatus, ResourceUsage}; use super::container_types::Container;
impl Container { impl Container {
/// Create a new container reference with the given name /// Create a new container reference with the given name

View File

@ -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(mut self) -> Self { pub fn reset(self) -> Self {
let name = self.name; let name = self.name;
let image = self.image.clone(); let image = self.image.clone();

View File

@ -1,10 +1,9 @@
// 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, Value}; use serde_json::{self};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Represents a container image /// Represents a container image