@@ -340,18 +340,20 @@ def filter(path):
340
340
@click .command ()
341
341
@click .argument ("pod_name" , type = str , default = "" )
342
342
@click .option ("--follow" , "-f" , is_flag = True , default = False , help = "Follow logs" )
343
- def logs (pod_name : str , follow : bool ):
343
+ @click .option ("--namespace" , type = str , default = "default" , show_default = True )
344
+ def logs (pod_name : str , follow : bool , namespace : str ):
344
345
"""Show the logs of a pod"""
345
- return _logs (pod_name , follow )
346
+ return _logs (pod_name , follow , namespace )
346
347
347
348
348
- def _logs (pod_name : str , follow : bool ):
349
- namespace = get_default_namespace ()
349
+ def _logs (pod_name : str , follow : bool , namespace : Optional [str ] = None ):
350
+ if not namespace :
351
+ namespace = get_default_namespace ()
350
352
351
353
if pod_name == "" :
352
354
try :
353
355
pods = get_pods ()
354
- pod_list = [item .metadata .name for item in pods ]
356
+ pod_list = [f" { item .metadata .name } : { item . metadata . namespace } " for item in pods ]
355
357
except Exception as e :
356
358
print (f"Could not fetch any pods in namespace { namespace } : { e } " )
357
359
return
@@ -369,7 +371,7 @@ def _logs(pod_name: str, follow: bool):
369
371
]
370
372
selected = inquirer .prompt (q , theme = GreenPassion ())
371
373
if selected :
372
- pod_name = selected ["pod" ]
374
+ pod_name , pod_namespace = selected ["pod" ]. split ( ": " )
373
375
else :
374
376
return # cancelled by user
375
377
0 commit comments