pub async fn shell(mf: &Manifest, cmd: Option<Vec<&str>>) -> Result<()> {
    // TODO: kubectl auth can-i create pods/exec

    let target = format!("{}/{}", mf.workload.to_string(), mf.name);
    debug!("Shelling into {}", target);

    // kubectl exec -it deployment/$pod sh
    let mut execargs = vec![
        "exec".into(),
        format!("-n={}", mf.namespace),
        "-it".into(),
        target.clone(),
    ];
    if let Some(cmdu) = cmd.clone() {
        for c in cmdu {
            execargs.push(c.into())
        }
    } else {
        let trybash = vec![
            "exec".into(),
            format!("-n={}", mf.namespace),
            target,
            "which".into(),
            "bash".into(),
        ];
        // kubectl exec $pod which bash
        // returns a non-zero rc if not found generally
        let shexe = match kexec(trybash).await {
            Ok(o) => {
                debug!("Got {:?}", o);
                "bash".into()
            }
            Err(e) => {
                warn!("No bash in container, falling back to `sh`");
                debug!("Error: {}", e);
                "sh".into()
            }
        };
        execargs.push(shexe);
    }
    kexec(execargs).await?;
    Ok(())
}
/// Shell into a pod associated with a workload
Shell into a pod associated with a workload
Shell into a pod associated with a workload
pub async fn shell(mf: &Manifest, cmd: Option<Vec<&str>>) -> Result<()> {
    // TODO: kubectl auth can-i create pods/exec
    let target = format!("{}/{}", mf.workload.to_string(), mf.name);
    debug!("Shelling into {}", target);
    // kubectl exec -it deployment/$pod sh
    let mut execargs = vec![
        "exec".into(),
        format!("-n={}", mf.namespace),
        "-it".into(),
        target.clone(),
    ];
    if let Some(cmdu) = cmd.clone() {
        for c in cmdu {
            execargs.push(c.into())
        }
    } else {
        let trybash = vec![
            "exec".into(),
            format!("-n={}", mf.namespace),
            target,
            "which".into(),
            "bash".into(),
        ];
        // kubectl exec $pod which bash
        // returns a non-zero rc if not found generally
        let shexe = match kexec(trybash).await {
            Ok(o) => {
                debug!("Got {:?}", o);
                "bash".into()
            }
            Err(e) => {
                warn!("No bash in container, falling back to `sh`");
                debug!("Error: {}", e);
                "sh".into()
            }
        };
        execargs.push(shexe);
    }
    kexec(execargs).await?;
    Ok(())
}
pub async fn shell ( mf : & Manifest , cmd : Option < Vec < & str > > ) -> Result < ( ) > { // TODO: kubectl auth can-i create pods/exec let target = format ! ( " " mf workload to_string ( ) mf name ) ; debug ! ( " " target ) ; // kubectl exec -it deployment/$pod sh let mut execargs = vec ! [ " " into ( ) format ( " " mf namespace ) " " into ( ) target clone ( ) ] ; if let Some ( cmdu ) = cmd . clone ( ) { for c in cmdu { execargs . push ( c . into ( ) ) } } else { let trybash = vec ! [ " " into ( ) format ( " " mf namespace ) target " " into ( ) " " into ( ) ] ; // kubectl exec $pod which bash // returns a non-zero rc if not found generally let shexe = match kexec ( trybash ) . await { Ok ( o ) => { debug ! ( " " o ) ; " " . into ( ) } Err ( e ) => { warn ! ( " " ) ; debug ! ( " " e ) ; " " . into ( ) } } ; execargs . push ( shexe ) ; } kexec ( execargs ) . await ? ; Ok ( ( ) ) }
Shell into a pod associated with a workload
Shell into a pod associated with a workload
mf
&Manifest
cmd
Option<Vec<&str>>
mf
&Manifest
cmd
Option<Vec<&str>>