pub mod error;
pub mod types;
pub mod validate;
pub use error::*;
pub use types::*;
pub use validate::*;
use validator::Validate;
pub fn from_yaml_str(yaml: &str) -> Result<DeploymentSpec, SpecError> {
let spec: DeploymentSpec = serde_yaml::from_str(yaml)?;
spec.validate().map_err(|e| {
SpecError::Validation(ValidationError {
kind: ValidationErrorKind::Generic {
message: e.to_string(),
},
path: String::new(),
})
})?;
validate_dependencies(&spec)?;
validate_unique_service_endpoints(&spec)?;
validate_cron_schedules(&spec)?;
validate_tunnels(&spec)?;
validate_wasm_configs(&spec)?;
Ok(spec)
}
pub fn from_yaml_file(path: &std::path::Path) -> Result<DeploymentSpec, SpecError> {
let content = std::fs::read_to_string(path)?;
from_yaml_str(&content)
}