kdebug 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kdebug
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Universal Kubernetes Debug Container Utility
5
5
  Project-URL: Homepage, https://github.com/jessegoodier/kdebug
6
6
  Project-URL: Repository, https://github.com/jessegoodier/kdebug
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "kdebug"
7
- version = "0.3.2"
7
+ version = "0.3.4"
8
8
  description = "Universal Kubernetes Debug Container Utility"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -138,6 +138,19 @@ def get_current_namespace() -> str:
138
138
  return output if output else "default"
139
139
 
140
140
 
141
+ def validate_cluster_connection(namespace: str) -> Optional[str]:
142
+ """Validate kubectl can connect to the cluster and namespace exists.
143
+
144
+ Returns None on success, or an error message string on failure.
145
+ """
146
+ cmd = f"{kubectl_base_cmd()} get namespace {namespace} -o name"
147
+ print_debug_command(cmd)
148
+ result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
149
+ if result.returncode != 0:
150
+ return result.stderr.strip()
151
+ return None
152
+
153
+
141
154
  def get_pod_by_name(pod_name: str, namespace: str) -> Optional[Dict]:
142
155
  """Get pod information by name."""
143
156
  print(
@@ -450,6 +463,14 @@ def select_pod(args) -> Optional[Dict]:
450
463
  """Select a pod based on provided arguments."""
451
464
  namespace = args.namespace or get_current_namespace()
452
465
 
466
+ # Validate cluster connection and namespace before proceeding
467
+ error = validate_cluster_connection(namespace)
468
+ if error:
469
+ print(
470
+ f"{colorize('✗ Error:', Colors.RED)} {error}"
471
+ )
472
+ return None
473
+
453
474
  # Direct pod selection
454
475
  if args.pod:
455
476
  return get_pod_by_name(args.pod, namespace)
File without changes
File without changes
File without changes