changed Dtos and Docker structs
This commit is contained in:
@@ -11,7 +11,7 @@ pub mod container;
|
||||
pub mod serverclientcomm;
|
||||
pub mod stats;
|
||||
|
||||
use crate::models::{DockerContainerDto, DockerContainerMetricDto};
|
||||
use crate::models::{DockerRegistrationDto, DockerMetricDto, DockerContainer};
|
||||
use bollard::{query_parameters::InspectContainerOptions, Docker};
|
||||
use std::error::Error;
|
||||
|
||||
@@ -49,14 +49,14 @@ impl DockerManager {
|
||||
/// Finds the Docker container running the agent by image name
|
||||
pub async fn get_client_container(
|
||||
&self,
|
||||
) -> Result<Option<DockerContainerDto>, Box<dyn Error + Send + Sync>> {
|
||||
) -> Result<Option<DockerContainer>, Box<dyn Error + Send + Sync>> {
|
||||
let containers = container::get_available_containers(&self.docker).await;
|
||||
let client_image = "watcher-agent";
|
||||
|
||||
Ok(containers
|
||||
.into_iter()
|
||||
.find(|c| c.image.contains(client_image))
|
||||
.map(|container| DockerContainerDto {
|
||||
.map(|container| DockerContainer {
|
||||
id: container.id,
|
||||
image: container.image,
|
||||
name: container.name,
|
||||
@@ -89,12 +89,12 @@ impl DockerManager {
|
||||
/// Gets all available containers as DTOs for registration
|
||||
pub async fn get_containers_for_registration(
|
||||
&self,
|
||||
) -> Result<Vec<DockerContainerDto>, Box<dyn Error + Send + Sync>> {
|
||||
) -> Result<Vec<DockerContainer>, Box<dyn Error + Send + Sync>> {
|
||||
let containers = container::get_available_containers(&self.docker).await;
|
||||
|
||||
Ok(containers
|
||||
.into_iter()
|
||||
.map(|container| DockerContainerDto {
|
||||
.map(|container| DockerContainer {
|
||||
id: container.id,
|
||||
image: container.image,
|
||||
name: container.name,
|
||||
@@ -105,7 +105,7 @@ impl DockerManager {
|
||||
/// Gets container metrics for all containers
|
||||
pub async fn get_container_metrics(
|
||||
&self,
|
||||
) -> Result<Vec<DockerContainerMetricDto>, Box<dyn Error + Send + Sync>> {
|
||||
) -> Result<Vec<DockerContainer>, Box<dyn Error + Send + Sync>> {
|
||||
let containers = container::get_available_containers(&self.docker).await;
|
||||
let mut metrics = Vec::new();
|
||||
|
||||
@@ -147,7 +147,7 @@ impl DockerManager {
|
||||
};
|
||||
|
||||
metrics.push(DockerContainerMetricDto {
|
||||
id: container.id,
|
||||
server_id: container.id,
|
||||
status: status,
|
||||
network: network_stats,
|
||||
cpu: cpu_stats,
|
||||
@@ -185,7 +185,7 @@ impl DockerManager {
|
||||
}
|
||||
|
||||
// Keep these as utility functions if needed, but they should use DockerManager internally
|
||||
impl DockerContainerDto {
|
||||
impl DockerContainer {
|
||||
/// Returns the container ID
|
||||
pub fn id(&self) -> &str {
|
||||
&self.id
|
||||
|
||||
Reference in New Issue
Block a user