Skip to content

Commit 36e4f3c

Browse files
committed
more wip changes
1 parent f18d236 commit 36e4f3c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

resources/charts/namespaces/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
type: "assets"
2+
namespaceName: "default-warnet-value"
23
users:
34
- name: warnet-user
45
roles:

src/warnet/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
DEFAULT_NAMESPACE = "warnet"
1515
LOGGING_NAMESPACE = "warnet-logging"
1616
INGRESS_NAMESPACE = "ingress"
17-
HELM_COMMAND = "helm upgrade --install --create-namespace"
17+
HELM_COMMAND = "helm upgrade --install"
1818

1919
# labels are applied to namespaces to help filter commands without relying on naming conventions
2020
# on the namespaces themselves. Namespaces containing tanks and commanders get the WARNET_ASSETS tag
2121
# whereas logging namespaces get the WARNET_LOGGING tag, and admin namespaces get the WARNET_ADMIN tag
2222
WARNET_ASSETS = "assets"
2323
WARNET_LOGGING = "logging"
2424
WARNET_ADMIN = "admin"
25+
WARNET_NAMESPACE_ANNOTATION = "dontremember"
2526

2627

2728
# Directories and files for non-python assets, e.g., helm charts, example scenarios, default configs

src/warnet/deploy.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def deploy(directory, debug, namespace):
5959
if namespace:
6060
click.echo("Cannot specify a --namespace when deploying a namespaces chart.")
6161
else:
62-
deploy_namespaces(directory)
62+
deploy_namespaces(directory, debug)
6363
else:
6464
click.echo(
6565
"Error: Neither network.yaml nor namespaces.yaml found in the specified directory."
@@ -233,21 +233,21 @@ def deploy_network(directory: Path, namespace_override: str, debug: bool = False
233233
Path(temp_override_file_path).unlink()
234234

235235

236-
def deploy_namespaces(directory: Path):
236+
def deploy_namespaces(directory: Path, debug: bool = False):
237237
namespaces_file_path = directory / NAMESPACES_FILE
238238
defaults_file_path = directory / DEFAULTS_NAMESPACE_FILE
239239

240240
with namespaces_file_path.open() as f:
241241
namespaces_file = yaml.safe_load(f)
242242

243243
for namespace in namespaces_file["namespaces"]:
244-
click.echo(f"Deploying namespace: {namespace.get('name')}")
244+
click.echo(f"Deploying namespace: {namespace.get('namespaceName')}")
245245
try:
246246
temp_override_file_path = Path()
247-
namespace_name = namespace.get("name")
248-
namespace_config_override = {k: v for k, v in namespace.items() if k != "name"}
247+
namespace_name = namespace.get("namespaceName")
248+
namespace_config_override = {k: v for k, v in namespace.items()}
249249

250-
cmd = f"{HELM_COMMAND} {namespace_name} {NAMESPACES_CHART_LOCATION} -f {defaults_file_path} --set type={WARNET_ASSETS}"
250+
cmd = f"{HELM_COMMAND} --create-namespace {namespace_name} {NAMESPACES_CHART_LOCATION} -f {defaults_file_path} --set type={WARNET_ASSETS}"
251251

252252
if namespace_config_override:
253253
with tempfile.NamedTemporaryFile(
@@ -257,6 +257,9 @@ def deploy_namespaces(directory: Path):
257257
temp_override_file_path = Path(temp_file.name)
258258
cmd = f"{cmd} -f {temp_override_file_path}"
259259

260+
if debug:
261+
cmd += " --debug"
262+
260263
if not stream_command(cmd):
261264
click.echo(f"Failed to run Helm command: {cmd}")
262265
return
@@ -266,6 +269,7 @@ def deploy_namespaces(directory: Path):
266269
finally:
267270
if temp_override_file_path.exists():
268271
temp_override_file_path.unlink()
272+
print("DONE!!!!!")
269273

270274

271275
def is_windows():

0 commit comments

Comments
 (0)