8
8
DEFAULTS_NAMESPACE_FILE ,
9
9
NAMESPACES_DIR ,
10
10
NAMESPACES_FILE ,
11
+ WARGAMES_NAMESPACE_PREFIX ,
11
12
)
12
13
from .process import run_command , stream_command
13
14
@@ -34,11 +35,13 @@ def namespaces():
34
35
35
36
@namespaces .command ()
36
37
def list ():
37
- """List all namespaces with 'warnet -' prefix"""
38
+ """List all namespaces with 'wargames -' prefix"""
38
39
cmd = "kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'"
39
40
res = run_command (cmd )
40
41
all_namespaces = res .split ()
41
- warnet_namespaces = [ns for ns in all_namespaces if ns .startswith ("warnet-" )]
42
+ warnet_namespaces = [
43
+ ns for ns in all_namespaces if ns .startswith (f"{ WARGAMES_NAMESPACE_PREFIX } " )
44
+ ]
42
45
43
46
if warnet_namespaces :
44
47
print ("Warnet namespaces:" )
@@ -52,14 +55,16 @@ def list():
52
55
@click .option ("--all" , "destroy_all" , is_flag = True , help = "Destroy all warnet- prefixed namespaces" )
53
56
@click .argument ("namespace" , required = False )
54
57
def destroy (destroy_all : bool , namespace : str ):
55
- """Destroy a specific namespace or all warnet- prefixed namespaces"""
58
+ """Destroy a specific namespace or all 'wargames-' prefixed namespaces"""
56
59
if destroy_all :
57
60
cmd = "kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'"
58
61
res = run_command (cmd )
59
62
60
63
# Get the list of namespaces
61
64
all_namespaces = res .split ()
62
- warnet_namespaces = [ns for ns in all_namespaces if ns .startswith ("warnet-" )]
65
+ warnet_namespaces = [
66
+ ns for ns in all_namespaces if ns .startswith (f"{ WARGAMES_NAMESPACE_PREFIX } " )
67
+ ]
63
68
64
69
if not warnet_namespaces :
65
70
print ("No warnet namespaces found to destroy." )
@@ -72,8 +77,8 @@ def destroy(destroy_all: bool, namespace: str):
72
77
else :
73
78
print (f"Destroyed namespace: { ns } " )
74
79
elif namespace :
75
- if not namespace .startswith ("warnet- " ):
76
- print ("Error: Can only destroy namespaces with 'warnet- ' prefix" )
80
+ if not namespace .startswith (f" { WARGAMES_NAMESPACE_PREFIX } " ):
81
+ print (f "Error: Can only destroy namespaces with '{ WARGAMES_NAMESPACE_PREFIX } ' prefix" )
77
82
return
78
83
79
84
destroy_cmd = f"kubectl delete namespace { namespace } "
0 commit comments