88 DEFAULTS_NAMESPACE_FILE ,
99 NAMESPACES_DIR ,
1010 NAMESPACES_FILE ,
11+ WARGAMES_NAMESPACE_PREFIX ,
1112)
1213from .process import run_command , stream_command
1314
@@ -34,11 +35,13 @@ def namespaces():
3435
3536@namespaces .command ()
3637def list ():
37- """List all namespaces with 'warnet -' prefix"""
38+ """List all namespaces with 'wargames -' prefix"""
3839 cmd = "kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'"
3940 res = run_command (cmd )
4041 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+ ]
4245
4346 if warnet_namespaces :
4447 print ("Warnet namespaces:" )
@@ -52,14 +55,16 @@ def list():
5255@click .option ("--all" , "destroy_all" , is_flag = True , help = "Destroy all warnet- prefixed namespaces" )
5356@click .argument ("namespace" , required = False )
5457def 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"""
5659 if destroy_all :
5760 cmd = "kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'"
5861 res = run_command (cmd )
5962
6063 # Get the list of namespaces
6164 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+ ]
6368
6469 if not warnet_namespaces :
6570 print ("No warnet namespaces found to destroy." )
@@ -72,8 +77,8 @@ def destroy(destroy_all: bool, namespace: str):
7277 else :
7378 print (f"Destroyed namespace: { ns } " )
7479 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" )
7782 return
7883
7984 destroy_cmd = f"kubectl delete namespace { namespace } "
0 commit comments