use of org.onosproject.k8snetworking.api.Constants.CLI_LABELS_LENGTH in project onos by opennetworkinglab.
the class K8sNamespaceListCommand method doExecute.
@Override
protected void doExecute() {
K8sNamespaceService service = get(K8sNamespaceService.class);
List<Namespace> namespaces = Lists.newArrayList(service.namespaces());
namespaces.sort(Comparator.comparing(n -> n.getMetadata().getName()));
String format = genFormatString(ImmutableList.of(CLI_NAME_LENGTH, CLI_PHASE_LENGTH, CLI_LABELS_LENGTH));
if (outputJson()) {
print("%s", json(namespaces));
} else {
print(format, "Name", "Phase", "Labels");
for (Namespace namespace : namespaces) {
print(format, StringUtils.substring(namespace.getMetadata().getName(), 0, CLI_NAME_LENGTH - CLI_MARGIN_LENGTH), namespace.getStatus().getPhase(), namespace.getMetadata() != null && namespace.getMetadata().getLabels() != null && !namespace.getMetadata().getLabels().isEmpty() ? StringUtils.substring(namespace.getMetadata().getLabels().toString(), 0, CLI_LABELS_LENGTH - CLI_MARGIN_LENGTH) : "");
}
}
}
Aggregations