@@ -335,18 +335,20 @@ def filter(path):
335335@click .command ()
336336@click .argument ("pod_name" , type = str , default = "" )
337337@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 ):
339340 """Show the logs of a pod"""
340- return _logs (pod_name , follow )
341+ return _logs (pod_name , follow , namespace )
341342
342343
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 ()
345347
346348 if pod_name == "" :
347349 try :
348350 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 ]
350352 except Exception as e :
351353 print (f"Could not fetch any pods in namespace { namespace } : { e } " )
352354 return
@@ -364,7 +366,7 @@ def _logs(pod_name: str, follow: bool):
364366 ]
365367 selected = inquirer .prompt (q , theme = GreenPassion ())
366368 if selected :
367- pod_name = selected ["pod" ]
369+ pod_name , pod_namespace = selected ["pod" ]. split ( ": " )
368370 else :
369371 return # cancelled by user
370372
0 commit comments