fn try_from(d: Deployment) -> Result<DeploySummary> {
        if let Some(status) = d.status {
            let ready = status.ready_replicas.unwrap_or(0);
            let unavailable = status.unavailable_replicas.unwrap_or(0);
            let replicas = status.replicas.unwrap_or(0);

            // Sometimes kube tells us in an obscure way that the rollout is done:
            let mut message = None;
            let mut new_replicas_available = false;
            if let Some(conds) = status.conditions {
                // This is a shortcut that works in kubernetes 1.15
                // We can't take advantage of this condition yet.
                if let Some(pcond) = conds.iter().find(|c| c.type_ == "Progressing") {
                    if let Some(reason) = &pcond.reason {
                        message = pcond.message.clone();
                        if reason == "NewReplicaSetAvailable" {
                            new_replicas_available = true;
                        }
                    }
                }
            }
            Ok(DeploySummary {
                replicas,
                unavailable,
                ready,
                message,
                new_replicas_available,
            })
        } else {
            bail!("Missing deployment status object")
        }
    }
/// Helper to convert the openapi Deployment to the useful info
Helper to convert the openapi Deployment to the useful info
Helper to convert the openapi Deployment to the useful info
fn try_from(d: Deployment) -> Result<DeploySummary> {
        if let Some(status) = d.status {
            let ready = status.ready_replicas.unwrap_or(0);
            let unavailable = status.unavailable_replicas.unwrap_or(0);
            let replicas = status.replicas.unwrap_or(0);
            // Sometimes kube tells us in an obscure way that the rollout is done:
            let mut message = None;
            let mut new_replicas_available = false;
            if let Some(conds) = status.conditions {
                // This is a shortcut that works in kubernetes 1.15
                // We can't take advantage of this condition yet.
                if let Some(pcond) = conds.iter().find(|c| c.type_ == "Progressing") {
                    if let Some(reason) = &pcond.reason {
                        message = pcond.message.clone();
                        if reason == "NewReplicaSetAvailable" {
                            new_replicas_available = true;
                        }
                    }
                }
            }
            Ok(DeploySummary {
                replicas,
                unavailable,
                ready,
                message,
                new_replicas_available,
            })
        } else {
            bail!("Missing deployment status object")
        }
    }
fn try_from ( d : Deployment ) -> Result < DeploySummary > { if let Some ( status ) = d . status { let ready = status . ready_replicas . unwrap_or ( 0 ) ; let unavailable = status . unavailable_replicas . unwrap_or ( 0 ) ; let replicas = status . replicas . unwrap_or ( 0 ) ; // Sometimes kube tells us in an obscure way that the rollout is done: let mut message = None ; let mut new_replicas_available = false ; if let Some ( conds ) = status . conditions { // This is a shortcut that works in kubernetes 1.15 // We can't take advantage of this condition yet. if let Some ( pcond ) = conds . iter ( ) . find ( | c | c . type_ == " " ) { if let Some ( reason ) = & pcond . reason { message = pcond . message . clone ( ) ; if reason == " " { new_replicas_available = true ; } } } } Ok ( DeploySummary { replicas , unavailable , ready , message , new_replicas_available , } ) } else { bail ! ( " " ) } }
Helper to convert the openapi Deployment to the useful info
Helper to convert the openapi Deployment to the useful info
d
Deployment
d
Deployment