Skip to content

get namespace by alias should return non terminated namespace first #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="staroid", # Replace with your own username
version="0.0.8",
version="0.0.9",
license='MIT',
author="Staroid",
author_email="support@staroid.com",
Expand Down
3 changes: 3 additions & 0 deletions staroid/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self, staroid):

def get(self, name):
clusters = self.get_all()
if clusters == None:
return None

cluster_found = None
for c in clusters:
if c.name() == name:
Expand Down
12 changes: 11 additions & 1 deletion staroid/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def access(self):
def url(self):
return self.__json["url"]

def created_date(self):
return self.__json["createdDate"]

def terminated_date(self):
return self.__json["terminatedDate"]

class NamespaceApi:
"""Namespace api"""

Expand Down Expand Up @@ -64,11 +70,15 @@ def get(self, instance_name):
if namespaces == None:
return None

removed = None
for ns in namespaces:
if ns.phase() == "REMOVED":
removed = ns
continue
if ns.alias() == instance_name:
return ns

return None
return removed

def get_by_id(self, instance_id):
r = self.__staroid._api_get(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def wait_for_phase(ns_api, ns, phase):
if max_wait == 0:
break

class TestCluster(unittest.TestCase):
class TestNamespace(unittest.TestCase):
@unittest.skipUnless(integration_test_ready(), "Integration test environment is not configured")
def test_crud_namespace(self):
# given
Expand Down