fn try_from(rs: ReplicaSet) -> Result<ReplicaSetSummary> {
        if let Some(status) = rs.status.clone() {
            let replicas = status.replicas;
            let ready = status.ready_replicas.unwrap_or(0);
            let mut ver = None;
            if let Some(spec) = &rs.spec {
                if let Some(tpl) = &spec.template {
                    if let Some(podspec) = &tpl.spec {
                        let containers = &podspec.containers;
                        let image = containers[0].image.clone().unwrap_or(":".to_string());
                        let tag = image.split(':').collect::<Vec<_>>()[1];
                        ver = Some(short_ver(tag));
                    }
                }
            };
            let version = ver.unwrap_or_else(|| "unknown version".to_string());
            let hash = match Meta::meta(&rs)
                .labels
                .clone()
                .unwrap_or_default()
                .get("pod-template-hash")
            {
                Some(h) => h.to_owned(),
                None => bail!("Need pod-template-hash from replicaset for {}", Meta::name(&rs)),
            };
            Ok(ReplicaSetSummary {
                hash,
                version,
                replicas,
                ready,
            })
        } else {
            bail!("Missing replicaset status object")
        }
    }
/// Helper to convert the openapi ReplicaSet to the useful info
Helper to convert the openapi ReplicaSet to the useful info
Helper to convert the openapi ReplicaSet to the useful info
fn try_from(rs: ReplicaSet) -> Result<ReplicaSetSummary> {
        if let Some(status) = rs.status.clone() {
            let replicas = status.replicas;
            let ready = status.ready_replicas.unwrap_or(0);
            let mut ver = None;
            if let Some(spec) = &rs.spec {
                if let Some(tpl) = &spec.template {
                    if let Some(podspec) = &tpl.spec {
                        let containers = &podspec.containers;
                        let image = containers[0].image.clone().unwrap_or(":".to_string());
                        let tag = image.split(':').collect::<Vec<_>>()[1];
                        ver = Some(short_ver(tag));
                    }
                }
            };
            let version = ver.unwrap_or_else(|| "unknown version".to_string());
            let hash = match Meta::meta(&rs)
                .labels
                .clone()
                .unwrap_or_default()
                .get("pod-template-hash")
            {
                Some(h) => h.to_owned(),
                None => bail!("Need pod-template-hash from replicaset for {}", Meta::name(&rs)),
            };
            Ok(ReplicaSetSummary {
                hash,
                version,
                replicas,
                ready,
            })
        } else {
            bail!("Missing replicaset status object")
        }
    }
fn try_from ( rs : ReplicaSet ) -> Result < ReplicaSetSummary > { if let Some ( status ) = rs . status . clone ( ) { let replicas = status . replicas ; let ready = status . ready_replicas . unwrap_or ( 0 ) ; let mut ver = None ; if let Some ( spec ) = & rs . spec { if let Some ( tpl ) = & spec . template { if let Some ( podspec ) = & tpl . spec { let containers = & podspec . containers ; let image = containers [ 0 ] . image . clone ( ) . unwrap_or ( " " . to_string ( ) ) ; let tag = image . split ( ':' ) . collect :: < Vec < _ > > ( ) [ 1 ] ; ver = Some ( short_ver ( tag ) ) ; } } } ; let version = ver . unwrap_or_else ( | | " " . to_string ( ) ) ; let hash = match Meta :: meta ( & rs ) . labels . clone ( ) . unwrap_or_default ( ) . get ( " " ) { Some ( h ) => h . to_owned ( ) , None => bail ! ( " " Meta name ( rs ) ) , } ; Ok ( ReplicaSetSummary { hash , version , replicas , ready , } ) } else { bail ! ( " " ) } }
Helper to convert the openapi ReplicaSet to the useful info
Helper to convert the openapi ReplicaSet to the useful info
rs
ReplicaSet
rs
ReplicaSet