Skip to content

Commit bb814d4

Browse files
committed
deploy: enable deploying to all user namespaces
1 parent 3dda811 commit bb814d4

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/warnet/deploy.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
NETWORK_FILE,
2323
WARGAMES_NAMESPACE_PREFIX,
2424
)
25-
from .k8s import get_default_namespace, wait_for_ingress_controller, wait_for_pod_ready
25+
from .k8s import (
26+
get_default_namespace,
27+
get_namespaces_by_prefix,
28+
wait_for_ingress_controller,
29+
wait_for_pod_ready,
30+
)
2631
from .process import stream_command
2732

2833

@@ -44,11 +49,28 @@ def validate_directory(ctx, param, value):
4449
callback=validate_directory,
4550
)
4651
@click.option("--debug", is_flag=True)
47-
@click.option("--namespace", type=str)
48-
def deploy(directory, debug, namespace):
52+
@click.option("--namespace", type=str, help="Specify a namespace in which to deploy the network")
53+
@click.option("--to-all-users", is_flag=True, help="Deploy network to all user namespaces")
54+
def deploy(directory, debug, namespace, to_all_users):
55+
"""Deploy a warnet with topology loaded from <directory>"""
56+
if to_all_users:
57+
namespaces = get_namespaces_by_prefix(WARGAMES_NAMESPACE_PREFIX)
58+
for namespace in namespaces:
59+
_deploy(directory, debug, namespace.metadata.name, False)
60+
else:
61+
_deploy(directory, debug, namespace, to_all_users)
62+
63+
64+
def _deploy(directory, debug, namespace, to_all_users):
4965
"""Deploy a warnet with topology loaded from <directory>"""
5066
directory = Path(directory)
5167

68+
if to_all_users:
69+
namespaces = get_namespaces_by_prefix(WARGAMES_NAMESPACE_PREFIX)
70+
for namespace in namespaces:
71+
deploy(directory, debug, namespace.metadata.name, False)
72+
return
73+
5274
if (directory / NETWORK_FILE).exists():
5375
dl = deploy_logging_stack(directory, debug)
5476
deploy_network(directory, debug, namespace=namespace)

0 commit comments

Comments
 (0)