diff --git a/README.md b/README.md index 2afffae..1d3b211 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,15 @@ get <-n namespace_name:optional> 1: CONSOLE.print("[red]Too many params passed in, run 'help' for help\n") continue - resource_name = commands_list[0] resources_raw_data = get_cluster_resources_raw_data( @@ -138,30 +155,45 @@ def main( if not resources_raw_data: CONSOLE.print(f"No resources found for {resource_kind} {resource_name} {namespace_name}") continue - actions_dict[action_name](resources_raw_data) + actions_dict[action_name](resources_raw_data, print_yaml) -def get_resources(resources_raw_data: List[Dict[str, Any]]) -> None: - # Print table of Namespace, Name - table = Table() - table.add_column("NAMESPACE") - table.add_column("NAME") - for raw_data in resources_raw_data: - table.add_row(raw_data["namespace"], raw_data["name"]) +def get_resources(resources_raw_data: List[Dict[str, Any]], print_yaml: bool = False, **kwargs: Dict[Any, Any]) -> None: + if print_yaml: + print_resource_yaml(resources_raw_data=resources_raw_data) + else: + # Print table of Namespace, Name + table = Table() + table.add_column("NAMESPACE") + table.add_column("NAME") + for raw_data in resources_raw_data: + table.add_row(raw_data["namespace"], raw_data["name"]) + CONSOLE.print(table) + - CONSOLE.print(table) +def print_resource_yaml(resources_raw_data: List[Dict[str, Any]]) -> None: + for raw_data in resources_raw_data: + # Read resource yaml file from path in raw_data["yaml_file"] + try: + with open(raw_data["yaml_file"]) as fd: + resource_yaml_content = fd.read() + except (FileNotFoundError, IOError) as e: + CONSOLE.print(f"[red]Error opening file {raw_data['yaml_file']}: {e}") + continue + CONSOLE.print(resource_yaml_content) + CONSOLE.print("-" * os.get_terminal_size().columns) -def get_logs() -> None: +def get_logs(**kwargs: Dict[Any, Any]) -> None: pass -def get_describe() -> None: +def get_describe(**kwargs: Dict[Any, Any]) -> None: pass -def print_help() -> None: +def print_help(**kwargs: Dict[Any, Any]) -> None: pass