Skip to content

Commit

Permalink
Ingress table format
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnedo committed Jul 30, 2024
1 parent 6100f26 commit eca4894
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/get/ingress.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::collections::HashMap;
use chrono::SecondsFormat;
use k8s_openapi::api::batch::v1::CronJob;
use k8s_openapi::api::networking::v1::Ingress;
use crate::filestore::ObjectListItem;
use crate::get::{Lister};
use crate::get::lister::NameFilters;
Expand All @@ -18,7 +20,7 @@ impl Lister<ObjectListItem> for IngresssLister {

fn print(&self, resources: Vec<ObjectListItem>) {
macro_rules! cols {
() => ("{0: <15} {1: <15} {2: <15} {3: <15} {4: <15} {5: <15} {6: <15}")
() => ("{0: <15} {1: <15} {2: <15} {3: <25} {4: <15} {5: <15} {6: <15}")
}
println!(
cols!(),
Expand All @@ -29,12 +31,16 @@ impl Lister<ObjectListItem> for IngresssLister {
acc
});

for (name, item) in map {
let hosts = "TODO";
let age = age(item.first().unwrap().created_at);
let address = "TODO";
let class = "TODO";
let ports = "TODO";
for (name, items) in map {
let first = items.first().unwrap();
let ingress: Ingress = serde_yaml::from_value(first.manifest.as_ref().unwrap().clone()).unwrap_or_default();
let spec = ingress.spec.unwrap_or_default();

let hosts = spec.rules.unwrap_or_default().iter().map(|r| r.host.clone().unwrap_or_default()).collect::<Vec<String>>().join(",");
let age = age(first.created_at);
let address = "";
let class = "external";
let ports = "80,443";
println!(
cols!(),
name.namespace, name.name, class, hosts, address, ports, age
Expand Down

0 comments on commit eca4894

Please sign in to comment.