From 9566215f9eb6f1c7d28ec9d6986e87e420fa5899 Mon Sep 17 00:00:00 2001 From: Bogdan Tintor Date: Mon, 26 Aug 2024 16:29:54 +0200 Subject: [PATCH] CTX-6321: Discussion changes --- coretex/cli/commands/node.py | 2 +- coretex/cli/modules/node.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/coretex/cli/commands/node.py b/coretex/cli/commands/node.py index d47ccd49..fe795597 100644 --- a/coretex/cli/commands/node.py +++ b/coretex/cli/commands/node.py @@ -158,7 +158,7 @@ def config(advanced: bool) -> None: nodeConfig = NodeConfiguration.load() node_module.stop(nodeConfig.id) except (ConfigurationNotFound, InvalidConfiguration): - node_module.stop(nodeConfig.id) + node_module.stop() try: nodeConfig = NodeConfiguration.load() diff --git a/coretex/cli/modules/node.py b/coretex/cli/modules/node.py index b88272f7..530f3b0c 100644 --- a/coretex/cli/modules/node.py +++ b/coretex/cli/modules/node.py @@ -497,17 +497,23 @@ def getNodeVersion() -> Optional[str]: if isRunning(): imageName = docker.getContainerImageName(config_defaults.DOCKER_CONTAINER_NAME) - image_info = docker.imageInspect(imageName) - repo_digests = image_info.get("RepoDigests", []) - if not isinstance(repo_digests, list): - return 'Unknown version' + imageInfo = docker.imageInspect(imageName) + repoDigests = imageInfo.get("RepoDigests", []) + if not isinstance(repoDigests, list) and len(repoDigests) > 0: + return "Unknown version" - digest = repo_digests[0] + digest = repoDigests[0] if not isinstance(digest, str): # Assuming the format is "image_name@sha256:" return "Unknown version" else: - return digest.split("@")[1].split(":")[1][:12] if "@" in repo_digests[0] else "Unknown version" + return digest.split("@")[1].split(":")[1][:12] if "@" in repoDigests[0] else "Unknown version" + + except ConfigurationNotFound: + ui.errorEcho("Node configuration not found.") + + except InvalidConfiguration as ex: + for error in ex.errors: + ui.errorEcho(error) - except Exception as ex: - return f"Unable to retrieve version of Node. Reason: {ex}." + return f"Unable to retrieve version of Node" \ No newline at end of file