Skip to content

Commit

Permalink
updated pod_manager to exit
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-a12 committed Sep 5, 2024
1 parent 784d0e1 commit 4f0407d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions kubessh/pod_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ async def get_client_input(self, prompt_message):
user_input = b""
tmp = b""

while tmp != b'\r':
while True:
tmp = await self.process.stdin.read(1)
if not tmp:
if not tmp or tmp == b'\r':
break
user_input += tmp
self.process.stdout.write(user_input + b'\r')
self.process.stdout.write(tmp)

return user_input.decode('utf-8').strip()

Expand Down Expand Up @@ -167,7 +167,7 @@ async def pod_management_client(self, pod_name):

await self.create_pod(username, pod_name=new_pod_name)

elif user_input =='4':
elif user_input == '4':
if len(matching_pods) < 1:
self.process.stdout.write(b"\r\nNo pods to delete.\r\n\n")
continue
Expand All @@ -189,6 +189,11 @@ async def pod_management_client(self, pod_name):
await self.delete_pod(new_pod_name)
self.process.stdout.write(f"\r\n'{pod_name}' is deleted.\r\n".encode('ascii'))

elif user_input.lower() in ('q', 'exit'):
self.process.stdout.write(b"\r\n")
self.process.exit(0)
break

async def pod_management_developer(self):
while True:
print("\nEnter '1' to list all pods, '2' to search for pods, '3' to create pod, '4' to delete pod.")
Expand Down

0 comments on commit 4f0407d

Please sign in to comment.