added commentation
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
|
||||
//! Docker container utilities for WatcherAgent
|
||||
//!
|
||||
//! Provides functions to list and process Docker containers using the Bollard library.
|
||||
//!
|
||||
use crate::models::DockerContainer;
|
||||
|
||||
use bollard::query_parameters::{ListContainersOptions};
|
||||
@@ -6,6 +11,13 @@ use bollard::Docker;
|
||||
|
||||
|
||||
|
||||
/// Returns a list of available Docker containers.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `docker` - Reference to a Bollard Docker client.
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Vec<DockerContainer>` - Vector of Docker container info.
|
||||
pub async fn get_available_container(docker: &Docker) -> Vec<DockerContainer> {
|
||||
println!("=== DOCKER CONTAINER LIST ===");
|
||||
|
||||
@@ -67,32 +79,15 @@ pub async fn get_available_container(docker: &Docker) -> Vec<DockerContainer> {
|
||||
containers_list
|
||||
}
|
||||
|
||||
/*pub fn extract_client_container_id(line: &str) -> Option<String> {
|
||||
// Split by slashes and take the last part
|
||||
if let Some(last_part) = line.split('/').last() {
|
||||
let last_part = last_part.trim();
|
||||
|
||||
// Remove common suffixes
|
||||
let clean_id = last_part
|
||||
.trim_end_matches(".scope")
|
||||
.trim_start_matches("docker-")
|
||||
.trim_start_matches("crio-")
|
||||
.trim_start_matches("containerd-");
|
||||
|
||||
// Check if it looks like a container ID (hex characters)
|
||||
if clean_id.chars().all(|c| c.is_ascii_hexdigit()) && clean_id.len() >= 12 {
|
||||
return Some(clean_id.to_string());
|
||||
}
|
||||
|
||||
// If it's not pure hex, try to extract hex sequence
|
||||
let hex_part: String = clean_id.chars()
|
||||
.take_while(|c| c.is_ascii_hexdigit())
|
||||
.collect();
|
||||
|
||||
if hex_part.len() >= 12 {
|
||||
return Some(hex_part);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}*/
|
||||
/*
|
||||
/// Extracts a Docker container ID from a string line.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `line` - The input string containing a container ID or related info.
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Option<String>` - The extracted container ID if found.
|
||||
pub fn extract_client_container_id(line: &str) -> Option<String> {
|
||||
// ...existing code...
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user