Skip to content

Commit

Permalink
refactoring to ask if the right cluster is selected on every action
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMops committed Jul 3, 2024
1 parent 686f3c6 commit 0945f12
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
50 changes: 26 additions & 24 deletions cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ def choose_option() -> None:
"""
kuber: Kuber = Kuber()

print(f'You are connected to {kuber.show_active_context()}\n')

questions = [
inquirer.List(
'option',
message="Is this the correct cluster? ",
choices=['Yes',
'No',
'Exit'
],
),
]
answers: dict = inquirer.prompt(questions)

match answers["option"]:
case "No":
print("Please connect to the right cluster and try again")
exit(0)
case "Yes":
pass
case "Exit":
exit(0)

questions = [
inquirer.List(
'option',
Expand All @@ -47,6 +24,7 @@ def choose_option() -> None:
]
answers: dict = inquirer.prompt(questions)
click.echo(f'You chose: {answers["option"]}')

match answers["option"]:
case "Exit":
exit(0)
Expand Down Expand Up @@ -91,4 +69,28 @@ def choose_namespace(ns_list: list) -> str:
answers: dict = inquirer.prompt(questions)
# click.echo(f'You chose: {answers["option"]}')

return answers["option"]
return answers["option"]

def show_connected_cluster(kuber) -> None:
print(f'You are connected to {kuber.show_active_context()}\n')

questions = [
inquirer.List(
'option',
message="Is this the correct cluster? ",
choices=['Yes',
'No',
'Exit'
],
),
]
answers: dict = inquirer.prompt(questions)

match answers["option"]:
case "No":
print("Please connect to the right cluster and try again")
exit(0)
case "Yes":
pass
case "Exit":
exit(0)
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

if __name__ == '__main__':
Kuber.load_kube_config()
cli.show_connected_cluster(kuber=Kuber())
cli.choose_option()


Expand Down

0 comments on commit 0945f12

Please sign in to comment.