Raise properly on login authentication errors
@@ -24,9 +24,12 @@ def login():
try:
kubernetes.config.load_incluster_config() # cluster env vars
logger.debug("configured in cluster with service account")
- except kubernetes.config.ConfigException:
+ except kubernetes.config.ConfigException as e1:
+ try:
kubernetes.config.load_kube_config() # developer's config files
logger.debug("configured via kubeconfig file")
+ except kubernetes.config.ConfigException as e2:
+ raise LoginError(f"Cannot authenticate neither in-cluster, nor via kubeconfig.")
# Make a sample API call to ensure the login is successful,
# and convert some of the known exceptions to the CLI hints.
