Skip to content

Commit 2014f09

Browse files
committed
remove deadcode from namespaces.py
1 parent dc52ac1 commit 2014f09

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

src/warnet/namespaces.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import shutil
2-
import tempfile
32
from importlib.resources import files
43
from pathlib import Path
54

65
import click
7-
import yaml
86

97
from .process import run_command, stream_command
108

@@ -35,58 +33,9 @@ def namespaces():
3533
"""Namespaces commands"""
3634

3735

38-
@namespaces.command()
3936
@click.argument(
4037
"namespaces_dir", type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path)
4138
)
42-
def deploy(namespaces_dir: Path):
43-
"""Deploy namespaces with users from a <namespaces_file>"""
44-
namespaces_file_path = namespaces_dir / NAMESPACES_FILE
45-
defaults_file_path = namespaces_dir / DEFAULTS_FILE
46-
47-
with namespaces_file_path.open() as f:
48-
namespaces_file = yaml.safe_load(f)
49-
50-
# validate names before deploying
51-
names = [n.get("name") for n in namespaces_file["namespaces"]]
52-
for n in names:
53-
if not n.startswith("warnet-"):
54-
print(
55-
f"Failed to create namespace: {n}. Namespaces must start with a 'warnet-' prefix."
56-
)
57-
58-
# deploy namespaces
59-
for namespace in namespaces_file["namespaces"]:
60-
print(f"Deploying namespace: {namespace.get('name')}")
61-
try:
62-
temp_override_file_path = Path()
63-
namespace_name = namespace.get("name")
64-
# all the keys apart from name
65-
namespace_config_override = {k: v for k, v in namespace.items() if k != "name"}
66-
67-
cmd = (
68-
f"{HELM_COMMAND} {namespace_name} {BITCOIN_CHART_LOCATION} -f {defaults_file_path}"
69-
)
70-
71-
if namespace_config_override:
72-
with tempfile.NamedTemporaryFile(
73-
mode="w", suffix=".yaml", delete=False
74-
) as temp_file:
75-
yaml.dump(namespace_config_override, temp_file)
76-
temp_override_file_path = Path(temp_file.name)
77-
cmd = f"{cmd} -f {temp_override_file_path}"
78-
79-
if not stream_command(cmd):
80-
print(f"Failed to run Helm command: {cmd}")
81-
return
82-
except Exception as e:
83-
print(f"Error: {e}")
84-
return
85-
finally:
86-
if temp_override_file_path.exists():
87-
temp_override_file_path.unlink()
88-
89-
9039
@namespaces.command()
9140
def list():
9241
"""List all namespaces with 'warnet-' prefix"""

0 commit comments

Comments
 (0)