@@ -154,20 +154,22 @@ def down():
154154 def uninstall_release (namespace , release_name ):
155155 cmd = f"helm uninstall { release_name } --namespace { namespace } --wait"
156156 print (f"Initiating uninstall of { release_name } in namespace { namespace } " )
157- subprocess .run (cmd , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
158- return f"Uninstalled { release_name } in namespace { namespace } "
157+ return subprocess .run (cmd , shell = True , capture_output = True , text = True )
158+
159+ def delete_secrets (namespace , release_name ):
160+ cmd = f"kubectl delete secret --namespace { namespace } --selector owner=helm,name={ release_name } --ignore-not-found --wait"
161+ print (f"Initiated deletion of secrets for { release_name } in namespace { namespace } " )
162+ return subprocess .run (cmd , shell = True , capture_output = True , text = True )
159163
160164 def delete_pod (pod_name , namespace ):
161165 cmd = f"kubectl delete pod --ignore-not-found=true { pod_name } -n { namespace } --wait"
162166 print (f"Initiated deletion of pod: { pod_name } in namespace { namespace } " )
163- subprocess .run (cmd , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
164- return f"Deleted pod: { pod_name } in namespace { namespace } "
167+ return subprocess .run (cmd , shell = True , capture_output = True , text = True )
165168
166169 def delete_persistent_volume_claim (pvc_name , namespace ):
167170 cmd = f"kubectl delete pvc --ignore-not-found=true { pvc_name } -n { namespace } --wait"
168171 print (f"Initiated deletion of PVC: { pvc_name } in namespace { namespace } " )
169- subprocess .run (cmd , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
170- return f"Deleted PVC: { pvc_name } in namespace { namespace } "
172+ return subprocess .run (cmd , shell = True , capture_output = True , text = True )
171173
172174 if not can_delete_pods ():
173175 click .secho ("You do not have permission to bring down the network." , fg = "red" )
@@ -261,7 +263,11 @@ def delete_persistent_volume_claim(pvc_name, namespace):
261263
262264 # Wait for all tasks to complete and print results
263265 for future in as_completed (futures ):
264- console .print (f"[yellow]{ future .result ()} [/yellow]" )
266+ result = future .result ()
267+ if result .returncode == 0 :
268+ console .print (f"[yellow]{ result .stdout [:- 1 ]} [/yellow]" )
269+ else :
270+ console .print (f"[red]{ result .stderr [:- 1 ]} [/red]" )
265271
266272 with ThreadPoolExecutor (max_workers = 10 ) as executor :
267273 futures = []
@@ -280,7 +286,11 @@ def delete_persistent_volume_claim(pvc_name, namespace):
280286
281287 # Wait for all tasks to complete and print results
282288 for future in as_completed (futures ):
283- console .print (f"[yellow]{ future .result ()} [/yellow]" )
289+ result = future .result ()
290+ if result .returncode == 0 :
291+ console .print (f"[yellow]{ result .stdout [:- 1 ]} [/yellow]" )
292+ else :
293+ console .print (f"[red]{ result .stderr [:- 1 ]} [/red]" )
284294
285295 console .print ("[bold yellow]Teardown process initiated for all components.[/bold yellow]" )
286296 console .print ("[bold yellow]Note: Some processes may continue in the background.[/bold yellow]" )
0 commit comments