pub async fn template(mf: &Manifest, output: Option<PathBuf>) -> Result<String> {
    let hfile = format!("{}.helm.gen.yml", mf.name);
    values(&mf, &hfile).await?;

    let chart = mf.chart.clone().unwrap();
    if chart.starts_with("git@") {
        let (_tpl, tplerr, success) = clone_chart(&chart).await?;
        if !success {
            warn!("{} stderr: {}", chart, tplerr);
            bail!("helm failed to fetch template");
        }
    }
    // helm template with correct params
    let tplvec = vec![
        "template".into(),
        format!("charts/{}", mf.chart.clone().unwrap()),
        "-f".into(),
        hfile.clone(),
    ];
    // NB: this call does NOT need --tiller-namespace (offline call)
    let (tpl, tplerr, success) = hout(tplvec.clone()).await?;
    if !success {
        warn!("{} stderr: {}", tplvec.join(" "), tplerr);
        bail!("helm template failed");
    }
    if let Some(o) = &output {
        let pth = Path::new(".").join(o);
        debug!("Writing helm template for {} to {}", mf.name, pth.display());
        let mut f = File::create(&pth).await?;
        f.write_all(&tpl.as_bytes()).await?;
        f.sync_data().await?;
        debug!(
            "Wrote helm template for {} to {}: \n{}",
            mf.name,
            pth.display(),
            tpl
        );
        if let Err(e) = fs::remove_file(&hfile).await {
            warn!("Failed to delete file: {} {}", hfile, e);
        }
    }
    Ok(tpl)
}
/// Analogue of helm template
///
/// Generates helm values to disk, then passes it to helm template
Analogue of helm template
Generates helm values to disk, then passes it to helm template
Analogue of helm template Generates helm values to disk then passes it to helm template
pub async fn template(mf: &Manifest, output: Option<PathBuf>) -> Result<String> {
    let hfile = format!("{}.helm.gen.yml", mf.name);
    values(&mf, &hfile).await?;
    let chart = mf.chart.clone().unwrap();
    if chart.starts_with("git@") {
        let (_tpl, tplerr, success) = clone_chart(&chart).await?;
        if !success {
            warn!("{} stderr: {}", chart, tplerr);
            bail!("helm failed to fetch template");
        }
    }
    // helm template with correct params
    let tplvec = vec![
        "template".into(),
        format!("charts/{}", mf.chart.clone().unwrap()),
        "-f".into(),
        hfile.clone(),
    ];
    // NB: this call does NOT need --tiller-namespace (offline call)
    let (tpl, tplerr, success) = hout(tplvec.clone()).await?;
    if !success {
        warn!("{} stderr: {}", tplvec.join(" "), tplerr);
        bail!("helm template failed");
    }
    if let Some(o) = &output {
        let pth = Path::new(".").join(o);
        debug!("Writing helm template for {} to {}", mf.name, pth.display());
        let mut f = File::create(&pth).await?;
        f.write_all(&tpl.as_bytes()).await?;
        f.sync_data().await?;
        debug!(
            "Wrote helm template for {} to {}: \n{}",
            mf.name,
            pth.display(),
            tpl
        );
        if let Err(e) = fs::remove_file(&hfile).await {
            warn!("Failed to delete file: {} {}", hfile, e);
        }
    }
    Ok(tpl)
}
pub async fn template ( mf : & Manifest , output : Option < PathBuf > ) -> Result < String > { let hfile = format ! ( " " mf name ) ; values ( & mf , & hfile ) . await ? ; let chart = mf . chart . clone ( ) . unwrap ( ) ; if chart . starts_with ( " " ) { let ( _tpl , tplerr , success ) = clone_chart ( & chart ) . await ? ; if ! success { warn ! ( " " chart tplerr ) ; bail ! ( " " ) ; } } // helm template with correct params let tplvec = vec ! [ " " into ( ) format ( " " mf chart clone ( ) unwrap ( ) ) " " into ( ) hfile clone ( ) ] ; // NB: this call does NOT need --tiller-namespace (offline call) let ( tpl , tplerr , success ) = hout ( tplvec . clone ( ) ) . await ? ; if ! success { warn ! ( " " tplvec join ( " " ) tplerr ) ; bail ! ( " " ) ; } if let Some ( o ) = & output { let pth = Path :: new ( " " ) . join ( o ) ; debug ! ( " " mf name pth display ( ) ) ; let mut f = File :: create ( & pth ) . await ? ; f . write_all ( & tpl . as_bytes ( ) ) . await ? ; f . sync_data ( ) . await ? ; debug ! ( " \n " mf name pth display ( ) tpl ) ; if let Err ( e ) = fs :: remove_file ( & hfile ) . await { warn ! ( " " hfile e ) ; } } Ok ( tpl ) }
Analogue of helm template
Generates helm values to disk, then passes it to helm template
Analogue of helm template Generates helm values to disk then passes it to helm template
mf
&Manifest
output
Option<PathBuf>
mf
&Manifest
output
Option<PathBuf>