pub fn validate(services: Vec<Service>) -> Result<Vec<Service>, ValidationErrors> {
    let mut errors = vec![];
    services.iter().for_each(|service| {
        if service.command.is_empty() {
            errors.push(ValidationError::CommandEmpty {
                service: service.name.clone(),
            });
        }
        if !service.start_after.is_empty() {
            debug!(
                "Checking if all depedencies of '{}' exists, deps: {:?}",
                service.name, service.start_after
            );
        }
        service.start_after.iter().for_each(|name| {
            let passed = services.iter().any(|s| s.name == *name);
            if !passed {
                errors.push(ValidationError::MissingDependency {
                    before: name.into(),
                    after: service.name.clone(),
                });
            }
        });
    });
    if errors.is_empty() {
        Ok(services)
    } else {
        Err(ValidationErrors::new(errors))
    }
}
/// Runs some validation checks on the services.
/// TODO: if redirect output is file, check it exists and permissions.
Runs some validation checks on the services.
TODO: if redirect output is file, check it exists and permissions.
Runs some validation checks on the services . TODO : if redirect output is file check it exists and permissions .
pub fn validate(services: Vec<Service>) -> Result<Vec<Service>, ValidationErrors> {
    let mut errors = vec![];
    services.iter().for_each(|service| {
        if service.command.is_empty() {
            errors.push(ValidationError::CommandEmpty {
                service: service.name.clone(),
            });
        }
        if !service.start_after.is_empty() {
            debug!(
                "Checking if all depedencies of '{}' exists, deps: {:?}",
                service.name, service.start_after
            );
        }
        service.start_after.iter().for_each(|name| {
            let passed = services.iter().any(|s| s.name == *name);
            if !passed {
                errors.push(ValidationError::MissingDependency {
                    before: name.into(),
                    after: service.name.clone(),
                });
            }
        });
    });
    if errors.is_empty() {
        Ok(services)
    } else {
        Err(ValidationErrors::new(errors))
    }
}
pub fn validate ( services : Vec < Service > ) -> Result < Vec < Service > , ValidationErrors > { let mut errors = vec ! [ ] ; services . iter ( ) . for_each ( | service | { if service . command . is_empty ( ) { errors . push ( ValidationError :: CommandEmpty { service : service . name . clone ( ) , } ) ; } if ! service . start_after . is_empty ( ) { debug ! ( " " service name service start_after ) ; } service . start_after . iter ( ) . for_each ( | name | { let passed = services . iter ( ) . any ( | s | s . name == * name ) ; if ! passed { errors . push ( ValidationError :: MissingDependency { before : name . into ( ) , after : service . name . clone ( ) , } ) ; } } ) ; } ) ; if errors . is_empty ( ) { Ok ( services ) } else { Err ( ValidationErrors :: new ( errors ) ) } }
Runs some validation checks on the services.
Runs some validation checks on the services .
services
Vec<Service>
services
Vec<Service>