pub async fn regional_manifests(conf: &Config, reg: &Region) -> Result<()> {
    let available = shipcat_filebacked::available(conf, &reg).await?;

    let mut buffered = stream::iter(available)
        .map(move |mf| verify_manifest(mf.base.name, &conf, &reg))
        .buffer_unordered(16);

    let mut errs = vec![];
    let mut used_stream_names = vec![];
    let mut used_topic_names = vec![];
    let mut used_user_names = vec![];
    while let Some(r) = buffered.next().await {
        match r {
            Err(e) => errs.push(e),
            Ok(mf) => {
                // uniqueness validation
                for es in mf.eventStreams {
                    if used_stream_names.contains(&es.name) {
                        bail!("{} cannot reuse eventStream names {}", mf.name, es.name);
                    }
                    used_stream_names.push(es.name.clone());
                }
                if let Some(kr) = mf.kafkaResources {
                    for topic in kr.topics {
                        if used_topic_names.contains(&topic.name) {
                            bail!("{}, Topic name already exists: {}", mf.name, &topic.name);
                        }
                        if topic.name.contains('_') {
                            bail!(
                                "{}, cannot use underscores in kafka topic name: {}",
                                mf.name,
                                &topic.name
                            );
                        }
                        used_topic_names.push(topic.name.clone());
                    }
                    for user in kr.users {
                        if used_user_names.contains(&user.name) {
                            bail!("{}, Kafka User name already exists: {}", mf.name, &user.name);
                        }
                        used_user_names.push(user.name.clone());
                    }
                }
            }
        }
    }

    if !errs.is_empty() {
        for e in &errs {
            error!("{}", e.display_chain());
            debug!("{:?}", e.display_chain());
        }
        bail!("Invalid shipcat data in {} files", errs.len());
    }
    // TODO: cross reference uniqueness values here
    Ok(())
}
/// Validate all manifests in a service directory for a region
///
/// This is meant to replace `shipcat validate ..all_services`
/// This does not check secrets.
Validate all manifests in a service directory for a region
This is meant to replace `shipcat validate ..all_services`
This does not check secrets.
Validate all manifests in a service directory for a region This is meant to replace ` shipcat validate .. all_services ` This does not check secrets .
pub async fn regional_manifests(conf: &Config, reg: &Region) -> Result<()> {
    let available = shipcat_filebacked::available(conf, &reg).await?;
    let mut buffered = stream::iter(available)
        .map(move |mf| verify_manifest(mf.base.name, &conf, &reg))
        .buffer_unordered(16);
    let mut errs = vec![];
    let mut used_stream_names = vec![];
    let mut used_topic_names = vec![];
    let mut used_user_names = vec![];
    while let Some(r) = buffered.next().await {
        match r {
            Err(e) => errs.push(e),
            Ok(mf) => {
                // uniqueness validation
                for es in mf.eventStreams {
                    if used_stream_names.contains(&es.name) {
                        bail!("{} cannot reuse eventStream names {}", mf.name, es.name);
                    }
                    used_stream_names.push(es.name.clone());
                }
                if let Some(kr) = mf.kafkaResources {
                    for topic in kr.topics {
                        if used_topic_names.contains(&topic.name) {
                            bail!("{}, Topic name already exists: {}", mf.name, &topic.name);
                        }
                        if topic.name.contains('_') {
                            bail!(
                                "{}, cannot use underscores in kafka topic name: {}",
                                mf.name,
                                &topic.name
                            );
                        }
                        used_topic_names.push(topic.name.clone());
                    }
                    for user in kr.users {
                        if used_user_names.contains(&user.name) {
                            bail!("{}, Kafka User name already exists: {}", mf.name, &user.name);
                        }
                        used_user_names.push(user.name.clone());
                    }
                }
            }
        }
    }
    if !errs.is_empty() {
        for e in &errs {
            error!("{}", e.display_chain());
            debug!("{:?}", e.display_chain());
        }
        bail!("Invalid shipcat data in {} files", errs.len());
    }
    // TODO: cross reference uniqueness values here
    Ok(())
}
pub async fn regional_manifests ( conf : & Config , reg : & Region ) -> Result < ( ) > { let available = shipcat_filebacked :: available ( conf , & reg ) . await ? ; let mut buffered = stream :: iter ( available ) . map ( move | mf | verify_manifest ( mf . base . name , & conf , & reg ) ) . buffer_unordered ( 16 ) ; let mut errs = vec ! [ ] ; let mut used_stream_names = vec ! [ ] ; let mut used_topic_names = vec ! [ ] ; let mut used_user_names = vec ! [ ] ; while let Some ( r ) = buffered . next ( ) . await { match r { Err ( e ) => errs . push ( e ) , Ok ( mf ) => { // uniqueness validation for es in mf . eventStreams { if used_stream_names . contains ( & es . name ) { bail ! ( " " mf name es name ) ; } used_stream_names . push ( es . name . clone ( ) ) ; } if let Some ( kr ) = mf . kafkaResources { for topic in kr . topics { if used_topic_names . contains ( & topic . name ) { bail ! ( " " mf name topic name ) ; } if topic . name . contains ( '_' ) { bail ! ( " " mf name topic name ) ; } used_topic_names . push ( topic . name . clone ( ) ) ; } for user in kr . users { if used_user_names . contains ( & user . name ) { bail ! ( " " mf name user name ) ; } used_user_names . push ( user . name . clone ( ) ) ; } } } } } if ! errs . is_empty ( ) { for e in & errs { error ! ( " " e display_chain ( ) ) ; debug ! ( " " e display_chain ( ) ) ; } bail ! ( " " errs len ( ) ) ; } // TODO: cross reference uniqueness values here Ok ( ( ) ) }
Validate all manifests in a service directory for a region
This is meant to replace `shipcat validate ..all_services`
This does not check secrets.
Validate all manifests in a service directory for a region This is meant to replace ` shipcat validate .. all_services ` This does not check secrets .
conf
&Config
reg
&Region
conf
&Config
reg
&Region