diff --git a/python/src/mas/cli/aiservice/install/app.py b/python/src/mas/cli/aiservice/install/app.py index 053f1b8f5a..98bc8dc98c 100644 --- a/python/src/mas/cli/aiservice/install/app.py +++ b/python/src/mas/cli/aiservice/install/app.py @@ -526,7 +526,7 @@ def install(self, argv): self.lookupTargetArchitecture() if self.dynamicClient is None: - print_formatted_text(HTML("Error: The Kubernetes dynamic Client is not available. See log file for details")) + print_formatted_text(HTML("Error: Not successfully connected to a Kubernetes cluster. See log file for details")) exit(1) # Perform a check whether the cluster is set up for airgap install, this will trigger an early failure if the cluster is using the now diff --git a/python/src/mas/cli/aiservice/upgrade/app.py b/python/src/mas/cli/aiservice/upgrade/app.py index 8f732ef4a2..67f0902c0b 100644 --- a/python/src/mas/cli/aiservice/upgrade/app.py +++ b/python/src/mas/cli/aiservice/upgrade/app.py @@ -51,7 +51,7 @@ def upgrade(self, argv): self.lookupTargetArchitecture() if self.dynamicClient is None: - print_formatted_text(HTML("Error: The Kubernetes dynamic Client is not available. See log file for details")) + print_formatted_text(HTML("Error: Not successfully connected to a Kubernetes cluster. See log file for details")) sys.exit(1) if aiserviceInstanceId is None: diff --git a/python/src/mas/cli/backup/app.py b/python/src/mas/cli/backup/app.py index 58405ff784..1bb9527574 100644 --- a/python/src/mas/cli/backup/app.py +++ b/python/src/mas/cli/backup/app.py @@ -118,7 +118,7 @@ def backup(self, argv): self.connect() if self.dynamicClient is None: - self.fatalError("The Kubernetes dynamic Client is not available. See log file for details") + self.fatalError("Not successfully connected to a Kubernetes cluster. See log file for details") # Perform a check whether the cluster is set up for airgap install self.isAirgap() diff --git a/python/src/mas/cli/cli.py b/python/src/mas/cli/cli.py index abc08ce61d..bc01afe372 100644 --- a/python/src/mas/cli/cli.py +++ b/python/src/mas/cli/cli.py @@ -413,10 +413,12 @@ def lookupTargetArchitecture(self, architecture: str | None = None) -> None: if architecture is not None: self.architecture = architecture logger.debug(f"Target architecture (overridden): {self.architecture}") - else: + elif self.dynamicClient is not None: nodes = getNodes(self.dynamicClient) self.architecture = nodes[0]["status"]["nodeInfo"]["architecture"] logger.debug(f"Target architecture: {self.architecture}") + else: + return if self.architecture not in ["amd64", "s390x", "ppc64le"]: self.fatalError(f"Unsupported worker node architecture: {self.architecture}") diff --git a/python/src/mas/cli/install/app.py b/python/src/mas/cli/install/app.py index b7595d9b53..a3d3b95398 100644 --- a/python/src/mas/cli/install/app.py +++ b/python/src/mas/cli/install/app.py @@ -46,6 +46,7 @@ JsonValidator, OptimizerInstallPlanValidator, BucketPrefixValidator, + NotEmptyValidator, ) from mas.devops.ocp import ( @@ -1347,7 +1348,11 @@ def configApps(self): def configAppChannel(self, appId): versions = self.getCompatibleVersions(self.params["mas_channel"], appId) if len(versions) == 0: - self.params[f"mas_app_channel_{appId}"] = prompt(HTML(f"Custom channel for {appId}")) + self.promptForString( + f"Custom channel for {appId}", + f"mas_app_channel_{appId}", + validator=NotEmptyValidator(), + ) else: self.params[f"mas_app_channel_{appId}"] = versions[0] @@ -2502,7 +2507,7 @@ def install(self, argv): self.lookupTargetArchitecture() if self.dynamicClient is None: - print_formatted_text(HTML("Error: The Kubernetes dynamic Client is not available. See log file for details")) + print_formatted_text(HTML("Error: Not successfully connected to a Kubernetes cluster. See log file for details")) exit(1) # Perform a check whether the cluster is set up for airgap install, this will trigger an early failure if the cluster is using the now diff --git a/python/src/mas/cli/restore/app.py b/python/src/mas/cli/restore/app.py index 2b98d8baf2..9c5c2cda70 100644 --- a/python/src/mas/cli/restore/app.py +++ b/python/src/mas/cli/restore/app.py @@ -135,7 +135,7 @@ def restore(self, argv): self.connect() if self.dynamicClient is None: - self.fatalError("The Kubernetes dynamic Client is not available. See log file for details") + self.fatalError("Not successfully connected to a Kubernetes cluster. See log file for details") # Perform a check whether the cluster is set up for airgap install self.isAirgap() diff --git a/python/src/mas/cli/uninstall/app.py b/python/src/mas/cli/uninstall/app.py index d8fa72564d..f183d2956f 100644 --- a/python/src/mas/cli/uninstall/app.py +++ b/python/src/mas/cli/uninstall/app.py @@ -65,7 +65,7 @@ def uninstall(self, argv): logger.debug("MAS instance ID is set, so we assume already connected to the desired OCP") if self.dynamicClient is None: - self.fatalError("The Kubernetes dynamic Client is not available. See log file for details") + self.fatalError("Not successfully connected to a Kubernetes cluster. See log file for details") if instanceId is None: # Interactive mode diff --git a/python/src/mas/cli/update/app.py b/python/src/mas/cli/update/app.py index 9bfe374fb8..d685d4035c 100644 --- a/python/src/mas/cli/update/app.py +++ b/python/src/mas/cli/update/app.py @@ -100,7 +100,7 @@ def update(self, argv): self.connect() if self.dynamicClient is None: - self.fatalError("The Kubernetes dynamic Client is not available. See log file for details") + self.fatalError("Not successfully connected to a Kubernetes cluster. See log file for details") # Perform a check whether the cluster is set up for airgap install, this will trigger an early failure if the cluster is using the now # deprecated MaximoApplicationSuite ImageContentSourcePolicy instead of the new ImageDigestMirrorSet diff --git a/python/src/mas/cli/upgrade/app.py b/python/src/mas/cli/upgrade/app.py index 2a28f2fab2..d7dfd1ec9e 100644 --- a/python/src/mas/cli/upgrade/app.py +++ b/python/src/mas/cli/upgrade/app.py @@ -155,7 +155,7 @@ def upgrade(self, argv): self.lookupTargetArchitecture() if self.dynamicClient is None: - print_formatted_text(HTML("Error: The Kubernetes dynamic Client is not available. See log file for details")) + print_formatted_text(HTML("Error: Not successfully connected to a Kubernetes cluster. See log file for details")) sys.exit(1) if instanceId is None: diff --git a/python/src/mas/cli/validators.py b/python/src/mas/cli/validators.py index 55f2bc2e10..a051b40b97 100644 --- a/python/src/mas/cli/validators.py +++ b/python/src/mas/cli/validators.py @@ -232,3 +232,14 @@ def validate(self, document: Document) -> None: if not match(r"^.{1,4}$", bucketPrefix): raise ValidationError(message="Bucket prefix does not meet the requirement", cursor_position=len(bucketPrefix)) + + +class NotEmptyValidator(Validator): + def validate(self, document: Document) -> None: + """ + Validate that the input value is not empty + """ + value = document.text + + if not match(r"^.+$", value): + raise ValidationError(message="Enter a value", cursor_position=0)