Skip to content

Commit 2bb87ec

Browse files
committed
rename to get_namespaces_by_type
`get_namespaces_by_prefix` is now renamed to `get_namespaces_by_type` in anticipation of using labels in the future.
1 parent 5188108 commit 2bb87ec

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/warnet/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from rich import print as richprint
77

88
from .constants import NETWORK_DIR, WARGAMES_NAMESPACE_PREFIX
9-
from .k8s import get_kubeconfig_value, get_namespaces_by_prefix, get_service_accounts_in_namespace
9+
from .k8s import get_kubeconfig_value, get_namespaces_by_type, get_service_accounts_in_namespace
1010
from .namespaces import copy_namespaces_defaults, namespaces
1111
from .network import copy_network_defaults
1212
from .process import run_command
@@ -67,7 +67,7 @@ def create_kubeconfigs(kubeconfig_dir, token_duration):
6767
# TODO: choose a prefix convention and have it managed by the helm charts instead of requiring the
6868
# admin user to pipe through the correct string in multiple places. Another would be to use
6969
# labels instead of namespace naming conventions
70-
warnet_namespaces = get_namespaces_by_prefix(WARGAMES_NAMESPACE_PREFIX)
70+
warnet_namespaces = get_namespaces_by_type(WARGAMES_NAMESPACE_PREFIX)
7171

7272
for v1namespace in warnet_namespaces:
7373
namespace = v1namespace.metadata.name

src/warnet/deploy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .k8s import (
2626
get_default_namespace,
2727
get_default_namespace_or,
28-
get_namespaces_by_prefix,
28+
get_namespaces_by_type,
2929
wait_for_ingress_controller,
3030
wait_for_pod_ready,
3131
)
@@ -55,7 +55,7 @@ def validate_directory(ctx, param, value):
5555
def deploy(directory, debug, namespace, to_all_users):
5656
"""Deploy a warnet with topology loaded from <directory>"""
5757
if to_all_users:
58-
namespaces = get_namespaces_by_prefix(WARGAMES_NAMESPACE_PREFIX)
58+
namespaces = get_namespaces_by_type(WARGAMES_NAMESPACE_PREFIX)
5959
for namespace in namespaces:
6060
_deploy(directory, debug, namespace.metadata.name, False)
6161
else:
@@ -67,7 +67,7 @@ def _deploy(directory, debug, namespace, to_all_users):
6767
directory = Path(directory)
6868

6969
if to_all_users:
70-
namespaces = get_namespaces_by_prefix(WARGAMES_NAMESPACE_PREFIX)
70+
namespaces = get_namespaces_by_type(WARGAMES_NAMESPACE_PREFIX)
7171
for namespace in namespaces:
7272
deploy(directory, debug, namespace.metadata.name, False)
7373
return

src/warnet/k8s.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ def get_namespaces() -> list[V1Namespace]:
408408
return []
409409

410410

411-
def get_namespaces_by_prefix(prefix: str) -> list[V1Namespace]:
411+
def get_namespaces_by_type(namespace_type: str) -> list[V1Namespace]:
412412
"""
413413
Get all namespaces beginning with `prefix`. Returns empty list of no namespaces with the specified prefix are found.
414414
"""
415415
namespaces = get_namespaces()
416-
return [ns for ns in namespaces if ns.metadata.name.startswith(prefix)]
416+
return [ns for ns in namespaces if ns.metadata.name.startswith(namespace_type)]
417417

418418

419419
def get_service_accounts_in_namespace(namespace):

0 commit comments

Comments
 (0)