Skip to content

Commit 1f0a2de

Browse files
committed
add deploy to admin
This adds `deploy` to the admin section, but I'm not totally sold on having two deploy functions. The reason I went this route was to not complicate our `warnet deploy` function; that said, I think allowing a --namespace option to `warnet deploy` should be okay.
1 parent 3e05c58 commit 1f0a2de

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/warnet/admin.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import click
55
from rich import print as richprint
66

7-
from .constants import NETWORK_DIR
7+
from .constants import NETWORK_DIR, NETWORK_FILE
8+
from .deploy import deploy_network, validate_directory
89
from .k8s import get_kubeconfig_value, get_namespaces_by_prefix, get_service_accounts_in_namespace
910
from .namespaces import copy_namespaces_defaults, namespaces
1011
from .network import copy_network_defaults
@@ -125,3 +126,34 @@ def create_kubeconfigs(prefix: str, kubeconfig_dir, token_duration):
125126
"Users can then use by running `warnet auth <file>` or with kubectl by specifying the --kubeconfig flag or by setting the KUBECONFIG environment variable."
126127
)
127128
click.echo(f"Note: The tokens will expire after {token_duration} seconds.")
129+
130+
131+
@admin.command()
132+
@click.argument(
133+
"directory",
134+
type=click.Path(exists=True, file_okay=False, dir_okay=True),
135+
callback=validate_directory,
136+
)
137+
@click.option("--debug", is_flag=True)
138+
@click.option(
139+
"--namespace",
140+
default=None,
141+
type=None,
142+
help="The namespace in which to deploy the network",
143+
)
144+
def deploy(directory, debug, namespace):
145+
"""Deploy a warnet with topology loaded from <directory>"""
146+
directory = Path(directory)
147+
148+
if (directory / NETWORK_FILE).exists():
149+
# dl = deploy_logging_stack(directory, debug)
150+
deploy_network(directory, debug, namespace)
151+
# df = deploy_fork_observer(directory, debug)
152+
# if dl | df:
153+
# deploy_caddy(directory, debug)
154+
# elif (directory / NAMESPACES_FILE).exists():
155+
# deploy_namespaces(directory)
156+
else:
157+
click.echo(
158+
"Error: Neither network.yaml nor namespaces.yaml found in the specified directory."
159+
)

0 commit comments

Comments
 (0)