TablePrinter table = podsAsTable(pods);
return tableResults(table);
}
protected TablePrinter podsAsTable(PodListSchema pods) {
TablePrinter table = new TablePrinter();
table.columns("id", "image(s)", "host", "labels", "status");
List<PodSchema> items = pods.getItems();
if (items == null) {
items = Collections.EMPTY_LIST;
}
Filter<PodSchema> filter = KubernetesHelper.createPodFilter(filterText.getValue());
for (PodSchema item : items) {
if (filter.matches(item)) {
String id = item.getId();
CurrentState currentState = item.getCurrentState();
String status = "";
String host = "";
if (currentState != null) {
status = currentState.getStatus();
host = currentState.getHost();
}
Map<String, String> labelMap = item.getLabels();
String labels = KubernetesHelper.toLabelsString(labelMap);
DesiredState desiredState = item.getDesiredState();
if (desiredState != null) {
Manifest manifest = desiredState.getManifest();
if (manifest != null) {
List<ManifestContainer> containers = manifest.getContainers();
for (ManifestContainer container : containers) {
String image = container.getImage();
table.row(id, image, host, labels, status);
id = "";
host = "";
status = "";
labels = "";