Skip to content

Commit b70a867

Browse files
committed
control: remove --force from warnet down and make warnings BIGGER
1 parent 49adbed commit b70a867

2 files changed

Lines changed: 31 additions & 34 deletions

File tree

src/warnet/control.py

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,8 @@ def stop_all_scenarios(scenarios) -> None:
146146
console.print("[bold green]All scenarios have been stopped.[/bold green]")
147147

148148

149-
@click.option(
150-
"--force",
151-
is_flag=True,
152-
default=False,
153-
help="Skip confirmations",
154-
)
155149
@click.command()
156-
def down(force):
150+
def down():
157151
"""Bring down a running warnet quickly"""
158152

159153
def uninstall_release(namespace, release_name):
@@ -181,33 +175,36 @@ def delete_pod(pod_name, namespace):
181175
for release in releases:
182176
release_list.append({"namespace": namespace, "name": release["name"]})
183177

184-
if not force:
185-
affected_namespaces = set([entry["namespace"] for entry in release_list])
186-
namespace_listing = "\n ".join(affected_namespaces)
187-
confirmed = "confirmed"
188-
click.secho("Preparing to bring down the running Warnet...", fg="yellow")
189-
click.secho("The listed namespaces will be affected:", fg="yellow")
190-
click.secho(f" {namespace_listing}", fg="blue")
191-
192-
proj_answers = inquirer.prompt(
193-
[
194-
inquirer.Confirm(
195-
confirmed,
196-
message=click.style(
197-
"Do you want to bring down the running Warnet?", fg="yellow", bold=False
198-
),
199-
default=False,
178+
confirmed = "confirmed"
179+
click.secho("Preparing to bring down the running Warnet...", fg="yellow")
180+
181+
table = Table(title="PODS TO DESTROY", show_header=True, header_style="bold red")
182+
table.add_column("Namespace", style="red")
183+
table.add_column("Name", style="red")
184+
for release in release_list:
185+
table.add_row(release["namespace"], release["name"])
186+
console.print(table)
187+
click.secho("PODS WILL BE DESTROYED FOREVER IF YOU TYPE 'y'", fg="red", bg="white")
188+
189+
proj_answers = inquirer.prompt(
190+
[
191+
inquirer.Confirm(
192+
confirmed,
193+
message=click.style(
194+
"Do you want to bring down the running Warnet?", fg="yellow", bold=False
200195
),
201-
]
202-
)
203-
if not proj_answers:
204-
click.secho("Operation cancelled by user.", fg="yellow")
205-
sys.exit(0)
206-
if proj_answers[confirmed]:
207-
click.secho("Bringing down the warnet...", fg="yellow")
208-
else:
209-
click.secho("Operation cancelled by user", fg="yellow")
210-
sys.exit(0)
196+
default=False,
197+
),
198+
]
199+
)
200+
if not proj_answers:
201+
click.secho("Operation cancelled by user.", fg="yellow")
202+
sys.exit(0)
203+
if proj_answers[confirmed]:
204+
click.secho("Bringing down the warnet...", fg="yellow")
205+
else:
206+
click.secho("Operation cancelled by user", fg="yellow")
207+
sys.exit(0)
211208

212209
with ThreadPoolExecutor(max_workers=10) as executor:
213210
futures = []

src/warnet/k8s.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tarfile
55
import tempfile
66
from pathlib import Path
7-
from time import time, sleep
7+
from time import sleep, time
88
from typing import Optional
99

1010
import yaml

0 commit comments

Comments
 (0)