use crate::core::resources::ResourceSpec;
use blueprint_std::{collections::HashMap, path::PathBuf};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SshAuth {
Key(String),
Password(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SshConnection {
pub host: String,
pub port: u16,
pub user: String,
pub key_path: Option<PathBuf>,
pub password: Option<String>,
pub jump_host: Option<String>,
}
impl Default for SshConnection {
fn default() -> Self {
Self {
host: "localhost".to_string(),
port: 22,
user: "root".to_string(),
key_path: None,
password: None,
jump_host: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ContainerRuntime {
Docker,
Podman,
Containerd,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeploymentConfig {
pub name: String,
pub namespace: String,
pub restart_policy: RestartPolicy,
pub health_check: Option<HealthCheck>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum RestartPolicy {
Always,
#[default]
OnFailure,
Never,
}
impl Default for DeploymentConfig {
fn default() -> Self {
Self {
name: "blueprint-deployment".to_string(),
namespace: "default".to_string(),
restart_policy: RestartPolicy::default(),
health_check: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HealthCheck {
pub command: String,
pub interval: u32,
pub timeout: u32,
pub retries: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceLimits {
pub cpu_cores: Option<f64>,
pub memory_mb: Option<u64>,
pub disk_gb: Option<f64>,
pub network_bandwidth_mbps: Option<u32>,
}
impl ResourceLimits {
pub(super) fn from_spec(spec: &ResourceSpec) -> Self {
Self {
cpu_cores: Some(spec.cpu as f64),
memory_mb: Some((spec.memory_gb * 1024.0) as u64),
disk_gb: Some(spec.storage_gb as f64),
network_bandwidth_mbps: Some(1000), }
}
}
pub(super) struct ContainerDetails {
pub(super) status: String,
pub(super) ports: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoteDeployment {
pub host: String,
pub container_id: String,
pub runtime: ContainerRuntime,
pub status: String,
pub ports: HashMap<String, String>,
pub resource_limits: ResourceLimits,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NativeDeployment {
pub host: String,
pub service_name: String,
pub config_path: String,
pub status: String,
}