|
4 | 4 | import click
|
5 | 5 | from rich import print as richprint
|
6 | 6 |
|
7 |
| -from .constants import NETWORK_DIR |
| 7 | +from .constants import NETWORK_DIR, NETWORK_FILE |
| 8 | +from .deploy import deploy_network, validate_directory |
8 | 9 | from .k8s import get_kubeconfig_value, get_namespaces_by_prefix, get_service_accounts_in_namespace
|
9 | 10 | from .namespaces import copy_namespaces_defaults, namespaces
|
10 | 11 | from .network import copy_network_defaults
|
@@ -125,3 +126,34 @@ def create_kubeconfigs(prefix: str, kubeconfig_dir, token_duration):
|
125 | 126 | "Users can then use by running `warnet auth <file>` or with kubectl by specifying the --kubeconfig flag or by setting the KUBECONFIG environment variable."
|
126 | 127 | )
|
127 | 128 | 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