1pub mod error;
6pub mod types;
7pub mod validate;
8
9pub use error::*;
10pub use types::*;
11pub use validate::*;
12
13use validator::Validate;
14
15pub fn from_yaml_str(yaml: &str) -> Result<DeploymentSpec, SpecError> {
21 let spec: DeploymentSpec = serde_yaml::from_str(yaml)?;
22
23 spec.validate().map_err(|e| {
25 SpecError::Validation(ValidationError {
26 kind: ValidationErrorKind::Generic {
27 message: e.to_string(),
28 },
29 path: String::new(),
30 })
31 })?;
32
33 validate_dependencies(&spec)?;
35 validate_unique_service_endpoints(&spec)?;
36 validate_cron_schedules(&spec)?;
37 validate_tunnels(&spec)?;
38 validate_wasm_configs(&spec)?;
39
40 Ok(spec)
41}
42
43pub fn from_yaml_file(path: &std::path::Path) -> Result<DeploymentSpec, SpecError> {
49 let content = std::fs::read_to_string(path)?;
50 from_yaml_str(&content)
51}