Skip to content

Commit 3cf0fe0

Browse files
authored
get namespace by alias should return non terminated namespace first (#7)
1 parent f50abe8 commit 3cf0fe0

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="staroid", # Replace with your own username
8-
version="0.0.8",
8+
version="0.0.9",
99
license='MIT',
1010
author="Staroid",
1111
author_email="support@staroid.com",

staroid/cluster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def __init__(self, staroid):
4848

4949
def get(self, name):
5050
clusters = self.get_all()
51+
if clusters == None:
52+
return None
53+
5154
cluster_found = None
5255
for c in clusters:
5356
if c.name() == name:

staroid/namespace.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def access(self):
3434
def url(self):
3535
return self.__json["url"]
3636

37+
def created_date(self):
38+
return self.__json["createdDate"]
39+
40+
def terminated_date(self):
41+
return self.__json["terminatedDate"]
42+
3743
class NamespaceApi:
3844
"""Namespace api"""
3945

@@ -64,11 +70,15 @@ def get(self, instance_name):
6470
if namespaces == None:
6571
return None
6672

73+
removed = None
6774
for ns in namespaces:
75+
if ns.phase() == "REMOVED":
76+
removed = ns
77+
continue
6878
if ns.alias() == instance_name:
6979
return ns
7080

71-
return None
81+
return removed
7282

7383
def get_by_id(self, instance_id):
7484
r = self.__staroid._api_get(

tests/test_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def wait_for_phase(ns_api, ns, phase):
1616
if max_wait == 0:
1717
break
1818

19-
class TestCluster(unittest.TestCase):
19+
class TestNamespace(unittest.TestCase):
2020
@unittest.skipUnless(integration_test_ready(), "Integration test environment is not configured")
2121
def test_crud_namespace(self):
2222
# given

0 commit comments

Comments
 (0)