Skip to content
This repository has been archived by the owner on Jan 19, 2018. It is now read-only.

Commit

Permalink
Check if an OCP specific resource is being requested and use the oc_a…
Browse files Browse the repository at this point in the history
…pi URL
  • Loading branch information
dymurray committed Nov 14, 2016
1 parent 2b503eb commit ebc2aa3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions atomicapp/providers/lib/kubeshift/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def _generate_kurl(self, obj, namespace, name=None, params=None):
url = self.k8s_api
else:
url = urljoin(self.k8s_apis, "%s/" % api_version)
elif resource in self.oc_api_resources:
url = self.oc_api
else:
raise KubeOpenshiftError("No kind by that name: %s" % kind)

Expand Down
26 changes: 23 additions & 3 deletions tests/units/kubeshift/test_openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_connection(self, *args):
pass

def get_resources(self, *args):
return ['Pod', 'template']
return ['Pod', 'template', 'Route']

def get_groups(self, *args):
return {}
Expand All @@ -57,7 +57,7 @@ def cluster(self):


@mock.patch("atomicapp.providers.lib.kubeshift.openshift.KubeBase")
def test_create(mock_class):
def test_k8s_create(mock_class):
# Mock the API class
mock_class.return_value = FakeClient()
mock_class.get_resources.return_value = ['Pod']
Expand All @@ -69,9 +69,29 @@ def test_create(mock_class):
a = KubeOpenshiftClient(config)
a.create(k8s_object, "foobar")

@mock.patch("atomicapp.providers.lib.kubeshift.openshift.KubeBase")
def test_oc_create(mock_class):
mock_class.return_value = FakeClient()
mock_class.get_resources.return_value = ['Route']
mock_class.kind_to_resource_name.return_value = 'Route'

oc_object = {"apiVersion": "v1", "kind": "Route", "metadata": {"labels": {"name": "helloapache-route"}, "name": "helloapache-route"}, "spec": {
"host": "$endpoint", "to": [{"kind": "Service", "name": "helloapache-svc"}]}}
a = KubeOpenshiftClient(config)
a.create(oc_object, "foobar")

@mock.patch("atomicapp.providers.lib.kubeshift.openshift.KubeBase")
def test_oc_delete(mock_class):
mock_class.return_value = FakeClient()
mock_class.kind_to_resource_name.return_value = 'Route'

oc_object = {"apiVersion": "v1", "kind": "Route", "metadata": {"labels": {"name": "helloapache-route"}, "name": "helloapache-route"}, "spec": {
"host": "$endpoint", "to": [{"kind": "Service", "name": "helloapache-svc"}]}}
a = KubeOpenshiftClient(config)
a.delete(oc_object, "foobar")

@mock.patch("atomicapp.providers.lib.kubeshift.openshift.KubeBase")
def test_delete(mock_class):
def test_k8s_delete(mock_class):
# Mock the API class
mock_class.return_value = FakeClient()
mock_class.kind_to_resource_name.return_value = 'Pod'
Expand Down

0 comments on commit ebc2aa3

Please sign in to comment.