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