fn print_podlist(
    podlist: PodList,
    show_labels: bool,
    show_annot: bool,
    show_namespace: bool,
    regex: Option<Regex>,
    writer: &mut ClickWriter,
) -> PodList {
    let mut table = Table::new();
    let mut title_row = row!["####", "Name", "Ready", "Phase", "Age", "Restarts"];
    if show_labels {
        title_row.add_cell(Cell::new("Labels"));
    }
    if show_annot {
        title_row.add_cell(Cell::new("Annotations"));
    }
    if show_namespace {
        title_row.add_cell(Cell::new("Namespace"));
    }
    table.set_titles(title_row);

    let pods_specs = podlist.items.into_iter().map(|pod| {
        let mut specs = Vec::new();
        specs.push(CellSpec::new_index());
        specs.push(CellSpec::new_owned(pod.metadata.name.clone()));

        specs.push(CellSpec::new_owned(ready_str(&pod)));

        {
            let ps = phase_str(&pod);
            let ss = phase_style(&ps);
            specs.push(CellSpec::with_style_owned(ps, ss));
        }

        if let Some(ts) = pod.metadata.creation_timestamp {
            specs.push(CellSpec::new_owned(time_since(ts)));
        } else {
            specs.push(CellSpec::new("unknown"));
        }

        let restarts = if let Some(ref stats) = pod.status.container_statuses {
            stats.iter().fold(0, |acc, ref x| acc + x.restart_count)
        } else {
            0
        };
        specs.push(CellSpec::new_owned(format!("{}", restarts)));

        if show_labels {
            specs.push(CellSpec::new_owned(keyval_string(&pod.metadata.labels)));
        }

        if show_annot {
            specs.push(CellSpec::new_owned(keyval_string(
                &pod.metadata.annotations,
            )));
        }

        if show_namespace {
            specs.push(CellSpec::new_owned(match pod.metadata.namespace {
                Some(ref ns) => ns.clone(),
                None => "[Unknown]".to_owned(),
            }));
        }
        (pod, specs)
    });

    let filtered = match regex {
        Some(r) => ::table::filter(pods_specs, r),
        None => pods_specs.collect(),
    };

    ::table::print_table(&mut table, &filtered, writer);

    let final_pods = filtered.into_iter().map(|pod_spec| pod_spec.0).collect();
    PodList { items: final_pods }
}
/// Print out the specified list of pods in a pretty format
Print out the specified list of pods in a pretty format
Print out the specified list of pods in a pretty format
fn print_podlist(
    podlist: PodList,
    show_labels: bool,
    show_annot: bool,
    show_namespace: bool,
    regex: Option<Regex>,
    writer: &mut ClickWriter,
) -> PodList {
    let mut table = Table::new();
    let mut title_row = row!["####", "Name", "Ready", "Phase", "Age", "Restarts"];
    if show_labels {
        title_row.add_cell(Cell::new("Labels"));
    }
    if show_annot {
        title_row.add_cell(Cell::new("Annotations"));
    }
    if show_namespace {
        title_row.add_cell(Cell::new("Namespace"));
    }
    table.set_titles(title_row);
    let pods_specs = podlist.items.into_iter().map(|pod| {
        let mut specs = Vec::new();
        specs.push(CellSpec::new_index());
        specs.push(CellSpec::new_owned(pod.metadata.name.clone()));
        specs.push(CellSpec::new_owned(ready_str(&pod)));
        {
            let ps = phase_str(&pod);
            let ss = phase_style(&ps);
            specs.push(CellSpec::with_style_owned(ps, ss));
        }
        if let Some(ts) = pod.metadata.creation_timestamp {
            specs.push(CellSpec::new_owned(time_since(ts)));
        } else {
            specs.push(CellSpec::new("unknown"));
        }
        let restarts = if let Some(ref stats) = pod.status.container_statuses {
            stats.iter().fold(0, |acc, ref x| acc + x.restart_count)
        } else {
            0
        };
        specs.push(CellSpec::new_owned(format!("{}", restarts)));
        if show_labels {
            specs.push(CellSpec::new_owned(keyval_string(&pod.metadata.labels)));
        }
        if show_annot {
            specs.push(CellSpec::new_owned(keyval_string(
                &pod.metadata.annotations,
            )));
        }
        if show_namespace {
            specs.push(CellSpec::new_owned(match pod.metadata.namespace {
                Some(ref ns) => ns.clone(),
                None => "[Unknown]".to_owned(),
            }));
        }
        (pod, specs)
    });
    let filtered = match regex {
        Some(r) => ::table::filter(pods_specs, r),
        None => pods_specs.collect(),
    };
    ::table::print_table(&mut table, &filtered, writer);
    let final_pods = filtered.into_iter().map(|pod_spec| pod_spec.0).collect();
    PodList { items: final_pods }
}
fn print_podlist ( podlist : PodList , show_labels : bool , show_annot : bool , show_namespace : bool , regex : Option < Regex > , writer : & mut ClickWriter , ) -> PodList { let mut table = Table :: new ( ) ; let mut title_row = row ! [ " " " " " " " " " " " " ] ; if show_labels { title_row . add_cell ( Cell :: new ( " " ) ) ; } if show_annot { title_row . add_cell ( Cell :: new ( " " ) ) ; } if show_namespace { title_row . add_cell ( Cell :: new ( " " ) ) ; } table . set_titles ( title_row ) ; let pods_specs = podlist . items . into_iter ( ) . map ( | pod | { let mut specs = Vec :: new ( ) ; specs . push ( CellSpec :: new_index ( ) ) ; specs . push ( CellSpec :: new_owned ( pod . metadata . name . clone ( ) ) ) ; specs . push ( CellSpec :: new_owned ( ready_str ( & pod ) ) ) ; { let ps = phase_str ( & pod ) ; let ss = phase_style ( & ps ) ; specs . push ( CellSpec :: with_style_owned ( ps , ss ) ) ; } if let Some ( ts ) = pod . metadata . creation_timestamp { specs . push ( CellSpec :: new_owned ( time_since ( ts ) ) ) ; } else { specs . push ( CellSpec :: new ( " " ) ) ; } let restarts = if let Some ( ref stats ) = pod . status . container_statuses { stats . iter ( ) . fold ( 0 , | acc , ref x | acc + x . restart_count ) } else { 0 } ; specs . push ( CellSpec :: new_owned ( format ! ( " " restarts ) ) ) ; if show_labels { specs . push ( CellSpec :: new_owned ( keyval_string ( & pod . metadata . labels ) ) ) ; } if show_annot { specs . push ( CellSpec :: new_owned ( keyval_string ( & pod . metadata . annotations , ) ) ) ; } if show_namespace { specs . push ( CellSpec :: new_owned ( match pod . metadata . namespace { Some ( ref ns ) => ns . clone ( ) , None => " " . to_owned ( ) , } ) ) ; } ( pod , specs ) } ) ; let filtered = match regex { Some ( r ) => :: table :: filter ( pods_specs , r ) , None => pods_specs . collect ( ) , } ; :: table :: print_table ( & mut table , & filtered , writer ) ; let final_pods = filtered . into_iter ( ) . map ( | pod_spec | pod_spec . 0 ) . collect ( ) ; PodList { items : final_pods } }
Print out the specified list of pods in a pretty format
Print out the specified list of pods in a pretty format
podlist
PodList
show_labels
bool
show_annot
bool
show_namespace
bool
regex
Option<Regex>
writer
&mut ClickWriter
podlist
PodList
show_labels
bool
show_annot
bool
show_namespace
bool
regex
Option<Regex>
writer
&mut ClickWriter