From 0fafdc6fb6cd4778b2838ccb71d3e627e5f2d2ae Mon Sep 17 00:00:00 2001 From: Robusta Runner Date: Wed, 20 Mar 2024 19:53:57 +0100 Subject: for dgdevops :) --- robusta_krr/core/models/config.py | 1 + robusta_krr/formatters/table.py | 3 ++- robusta_krr/main.py | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py index 1d4e6a5..ab2939b 100644 --- a/robusta_krr/core/models/config.py +++ b/robusta_krr/core/models/config.py @@ -52,6 +52,7 @@ class Config(pd.BaseSettings): # Logging Settings format: str + show_cluster_name: bool strategy: str log_to_stderr: bool width: Optional[int] = pd.Field(None, ge=1) diff --git a/robusta_krr/formatters/table.py b/robusta_krr/formatters/table.py index a1c6e42..2cd8bbb 100644 --- a/robusta_krr/formatters/table.py +++ b/robusta_krr/formatters/table.py @@ -6,6 +6,7 @@ from rich.table import Table from robusta_krr.core.abstract import formatters from robusta_krr.core.models.allocations import RecommendationValue from robusta_krr.core.models.result import ResourceScan, ResourceType, Result +from robusta_krr.core.models.config import settings from robusta_krr.utils import resource_units NONE_LITERAL = "unset" @@ -86,7 +87,7 @@ def table(result: Result) -> Table: cluster_count = len(set(item.object.cluster for item in result.scans)) table.add_column("Number", justify="right", no_wrap=True) - if cluster_count > 1: + if cluster_count > 1 or settings.show_cluster_name: table.add_column("Cluster", style="cyan") table.add_column("Namespace", style="cyan") table.add_column("Name", style="cyan") diff --git a/robusta_krr/main.py b/robusta_krr/main.py index 83faeba..23c6f78 100644 --- a/robusta_krr/main.py +++ b/robusta_krr/main.py @@ -203,6 +203,9 @@ def load_commands() -> None: help=f"Output formatter ({', '.join(formatters.list_available())})", rich_help_panel="Logging Settings", ), + show_cluster_name: bool = typer.Option( + False, "--show-cluster-name", help="In table output, always show the cluster name even for a single cluster", rich_help_panel="Output Settings" + ), verbose: bool = typer.Option( False, "--verbose", "-v", help="Enable verbose mode", rich_help_panel="Logging Settings" ), @@ -254,6 +257,7 @@ def load_commands() -> None: openshift=openshift, max_workers=max_workers, format=format, + show_cluster_name=show_cluster_name, verbose=verbose, cpu_min_value=cpu_min_value, memory_min_value=memory_min_value, -- cgit v1.2.3 From 9fc5752297567790563ce1cd6e8f0212756a9373 Mon Sep 17 00:00:00 2001 From: Robusta Runner Date: Wed, 27 Mar 2024 05:57:46 +0200 Subject: bugfix for --show-cluster-name flag --- robusta_krr/formatters/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robusta_krr/formatters/table.py b/robusta_krr/formatters/table.py index 2cd8bbb..3d20b8e 100644 --- a/robusta_krr/formatters/table.py +++ b/robusta_krr/formatters/table.py @@ -110,7 +110,7 @@ def table(result: Result) -> Table: full_info_row = j == 0 cells: list[Any] = [f"[{item.severity.color}]{i + 1}.[/{item.severity.color}]"] - if cluster_count > 1: + if cluster_count > 1 or settings.show_cluster_name: cells.append(item.object.cluster if full_info_row else "") cells += [ item.object.namespace if full_info_row else "", -- cgit v1.2.3