use crate::models::{HealthCheckConfig, ServiceRole, ServiceType};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServicePack {
pub name: String,
pub version: String,
pub description: Option<String>,
pub author: Option<String>,
pub signatures: Vec<ServicePackSignature>,
#[serde(default)]
pub default_health_checks: HashMap<String, HealthCheckConfig>,
#[serde(default)]
pub default_log_paths: HashMap<String, Vec<String>>,
#[serde(default)]
pub default_systemd_units: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServicePackSignature {
pub name: String,
#[serde(rename = "type")]
pub service_type: ServiceType,
pub role: ServiceRole,
pub port: Option<u16>,
pub port_range: Option<(u16, u16)>,
pub process_pattern: Option<String>,
pub systemd_unit: Option<String>,
pub docker_image: Option<String>,
pub docker_container: Option<String>,
pub health_check: Option<HealthCheckConfig>,
#[serde(default)]
pub log_paths: Vec<String>,
#[serde(default)]
pub tags: Vec<String>,
}
impl ServicePack {
pub fn new(name: String, version: String) -> Self {
Self {
name,
version,
description: None,
author: None,
signatures: Vec::new(),
default_health_checks: HashMap::new(),
default_log_paths: HashMap::new(),
default_systemd_units: HashMap::new(),
}
}
}