pub fn verify(&self, conf: &Config, region: &Region) -> Result<()> {
        self.verify_region()?;
        // limit to 50 characters, alphanumeric, dashes for sanity.
        // 63 is kube dns limit (13 char suffix buffer)
        let re = Regex::new(r"^[0-9a-z\-]{1,50}$").unwrap();
        if !re.is_match(&self.name) {
            bail!("Please use a short, lower case service names with dashes");
        }
        if self.name.ends_with('-') || self.name.starts_with('-') {
            bail!("Please use dashes to separate words only");
        }

        self.verify_destination_rules(region)?;

        // TODO: remove?
        if let Some(ref dh) = self.dataHandling {
            dh.verify()?
        }

        if let Some(ref md) = self.metadata {
            md.verify(&conf.owners, &conf.allowedCustomMetadata)?;
        } else {
            bail!("Missing metadata for {}", self.name);
        }

        if self.external {
            warn!("Ignoring most validation for kube-external service {}", self.name);
            return Ok(());
        }

        if let Some(v) = &self.version {
            region.versioningScheme.verify(v)?;
        }

        // TODO [DIP-499]: Separate gate/kong params + adjust the checks
        if let Some(g) = &self.gate {
            if self.kongApis.is_empty() {
                bail!("Can't have a `gate` configuration without a `kong` one");
            }
            if g.public != self.publiclyAccessible {
                bail!("[Migration plan] `publiclyAccessible` and `gate.public` must be equal");
            }
        }

        // run the `Verify` trait on all imported structs
        // mandatory structs first
        if let Some(ref r) = self.resources {
            r.verify()?;
        } else {
            bail!("Resources is mandatory");
        }

        // optional/vectorised entries
        for d in &self.dependencies {
            d.verify()?;
        }

        for ha in &self.hostAliases {
            ha.verify()?;
        }
        for tl in &self.tolerations {
            tl.verify()?;
        }
        for r in &self.rbac {
            r.verify()?;
        }
        for pv in &self.persistentVolumes {
            pv.verify()?;
        }
        if let Some(ref cmap) = self.configs {
            cmap.verify()?;
        }
        for k in self.labels.keys() {
            if !conf.allowedLabels.contains(k) {
                bail!("Service: {} using label {} not defined in config", self.name, k)
            }
        }
        for es in &self.eventStreams {
            es.verify()?;
        }
        if let Some(kr) = &self.kafkaResources {
            kr.verify()?;
        }
        for pa in &self.prometheusAlerts {
            pa.verify(&self.name)?;
        }
        // misc minor properties
        if self.replicaCount.unwrap() == 0 {
            bail!("Need replicaCount to be at least 1");
        }
        if let Some(ref ru) = &self.rollingUpdate {
            ru.verify(self.replicaCount.unwrap())?;
        }

        self.env.verify()?;

        // internal errors - implicits set these!
        if self.image.is_none() {
            bail!("Image should be set at this point")
        }
        if self.imageSize.is_none() {
            bail!("imageSize must be set at this point");
        }
        if self.chart.is_none() {
            bail!("chart must be set at this point");
        }
        if self.namespace == "" {
            bail!("namespace must be set at this point");
        }
        if self.regions.is_empty() {
            bail!("No regions specified for {}", self.name);
        }
        if self.environment == "" {
            bail!("Service {} ended up with an empty environment", self.name);
        }
        if self.namespace == "" {
            bail!("Service {} ended up with an empty namespace", self.name);
        }

        // health check
        if self.health.is_none() && self.readinessProbe.is_none() {
            warn!("{} does not set a health check", self.name)
        }

        Ok(())
    }
/// Verify assumptions about manifest
///
/// Assumes the manifest has been populated with `implicits`
Verify assumptions about manifest
Assumes the manifest has been populated with `implicits`
Verify assumptions about manifest Assumes the manifest has been populated with ` implicits `
pub fn verify(&self, conf: &Config, region: &Region) -> Result<()> {
        self.verify_region()?;
        // limit to 50 characters, alphanumeric, dashes for sanity.
        // 63 is kube dns limit (13 char suffix buffer)
        let re = Regex::new(r"^[0-9a-z\-]{1,50}$").unwrap();
        if !re.is_match(&self.name) {
            bail!("Please use a short, lower case service names with dashes");
        }
        if self.name.ends_with('-') || self.name.starts_with('-') {
            bail!("Please use dashes to separate words only");
        }
        self.verify_destination_rules(region)?;
        // TODO: remove?
        if let Some(ref dh) = self.dataHandling {
            dh.verify()?
        }
        if let Some(ref md) = self.metadata {
            md.verify(&conf.owners, &conf.allowedCustomMetadata)?;
        } else {
            bail!("Missing metadata for {}", self.name);
        }
        if self.external {
            warn!("Ignoring most validation for kube-external service {}", self.name);
            return Ok(());
        }
        if let Some(v) = &self.version {
            region.versioningScheme.verify(v)?;
        }
        // TODO [DIP-499]: Separate gate/kong params + adjust the checks
        if let Some(g) = &self.gate {
            if self.kongApis.is_empty() {
                bail!("Can't have a `gate` configuration without a `kong` one");
            }
            if g.public != self.publiclyAccessible {
                bail!("[Migration plan] `publiclyAccessible` and `gate.public` must be equal");
            }
        }
        // run the `Verify` trait on all imported structs
        // mandatory structs first
        if let Some(ref r) = self.resources {
            r.verify()?;
        } else {
            bail!("Resources is mandatory");
        }
        // optional/vectorised entries
        for d in &self.dependencies {
            d.verify()?;
        }
        for ha in &self.hostAliases {
            ha.verify()?;
        }
        for tl in &self.tolerations {
            tl.verify()?;
        }
        for r in &self.rbac {
            r.verify()?;
        }
        for pv in &self.persistentVolumes {
            pv.verify()?;
        }
        if let Some(ref cmap) = self.configs {
            cmap.verify()?;
        }
        for k in self.labels.keys() {
            if !conf.allowedLabels.contains(k) {
                bail!("Service: {} using label {} not defined in config", self.name, k)
            }
        }
        for es in &self.eventStreams {
            es.verify()?;
        }
        if let Some(kr) = &self.kafkaResources {
            kr.verify()?;
        }
        for pa in &self.prometheusAlerts {
            pa.verify(&self.name)?;
        }
        // misc minor properties
        if self.replicaCount.unwrap() == 0 {
            bail!("Need replicaCount to be at least 1");
        }
        if let Some(ref ru) = &self.rollingUpdate {
            ru.verify(self.replicaCount.unwrap())?;
        }
        self.env.verify()?;
        // internal errors - implicits set these!
        if self.image.is_none() {
            bail!("Image should be set at this point")
        }
        if self.imageSize.is_none() {
            bail!("imageSize must be set at this point");
        }
        if self.chart.is_none() {
            bail!("chart must be set at this point");
        }
        if self.namespace == "" {
            bail!("namespace must be set at this point");
        }
        if self.regions.is_empty() {
            bail!("No regions specified for {}", self.name);
        }
        if self.environment == "" {
            bail!("Service {} ended up with an empty environment", self.name);
        }
        if self.namespace == "" {
            bail!("Service {} ended up with an empty namespace", self.name);
        }
        // health check
        if self.health.is_none() && self.readinessProbe.is_none() {
            warn!("{} does not set a health check", self.name)
        }
        Ok(())
    }
pub fn verify ( & self , conf : & Config , region : & Region ) -> Result < ( ) > { self . verify_region ( ) ? ; // limit to 50 characters, alphanumeric, dashes for sanity. // 63 is kube dns limit (13 char suffix buffer) let re = Regex :: new ( r"^[0-9a-z\-]{1,50}$" ) . unwrap ( ) ; if ! re . is_match ( & self . name ) { bail ! ( " " ) ; } if self . name . ends_with ( '-' ) || self . name . starts_with ( '-' ) { bail ! ( " " ) ; } self . verify_destination_rules ( region ) ? ; // TODO: remove? if let Some ( ref dh ) = self . dataHandling { dh . verify ( ) ? } if let Some ( ref md ) = self . metadata { md . verify ( & conf . owners , & conf . allowedCustomMetadata ) ? ; } else { bail ! ( " " self name ) ; } if self . external { warn ! ( " " self name ) ; return Ok ( ( ) ) ; } if let Some ( v ) = & self . version { region . versioningScheme . verify ( v ) ? ; } // TODO [DIP-499]: Separate gate/kong params + adjust the checks if let Some ( g ) = & self . gate { if self . kongApis . is_empty ( ) { bail ! ( " " ) ; } if g . public != self . publiclyAccessible { bail ! ( " " ) ; } } // run the `Verify` trait on all imported structs // mandatory structs first if let Some ( ref r ) = self . resources { r . verify ( ) ? ; } else { bail ! ( " " ) ; } // optional/vectorised entries for d in & self . dependencies { d . verify ( ) ? ; } for ha in & self . hostAliases { ha . verify ( ) ? ; } for tl in & self . tolerations { tl . verify ( ) ? ; } for r in & self . rbac { r . verify ( ) ? ; } for pv in & self . persistentVolumes { pv . verify ( ) ? ; } if let Some ( ref cmap ) = self . configs { cmap . verify ( ) ? ; } for k in self . labels . keys ( ) { if ! conf . allowedLabels . contains ( k ) { bail ! ( " " self name k ) } } for es in & self . eventStreams { es . verify ( ) ? ; } if let Some ( kr ) = & self . kafkaResources { kr . verify ( ) ? ; } for pa in & self . prometheusAlerts { pa . verify ( & self . name ) ? ; } // misc minor properties if self . replicaCount . unwrap ( ) == 0 { bail ! ( " " ) ; } if let Some ( ref ru ) = & self . rollingUpdate { ru . verify ( self . replicaCount . unwrap ( ) ) ? ; } self . env . verify ( ) ? ; // internal errors - implicits set these! if self . image . is_none ( ) { bail ! ( " " ) } if self . imageSize . is_none ( ) { bail ! ( " " ) ; } if self . chart . is_none ( ) { bail ! ( " " ) ; } if self . namespace == " " { bail ! ( " " ) ; } if self . regions . is_empty ( ) { bail ! ( " " self name ) ; } if self . environment == " " { bail ! ( " " self name ) ; } if self . namespace == " " { bail ! ( " " self name ) ; } // health check if self . health . is_none ( ) && self . readinessProbe . is_none ( ) { warn ! ( " " self name ) } Ok ( ( ) ) }
Verify assumptions about manifest
Assumes the manifest has been populated with `implicits`
Verify assumptions about manifest Assumes the manifest has been populated with ` implicits `
&self
conf
&Config
region
&Region
&self
conf
&Config
region
&Region