Skip to content
This repository was archived by the owner on Jan 19, 2018. It is now read-only.
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
1 change: 1 addition & 0 deletions atomicapp/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,5 +540,6 @@ def main():
cli = CLI()
cli.run()


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random newline added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdrage flake8 was updated last week and since the version is not locked down for CI testing it failed because the latest version requires a double newline between all def statements and the start of the program. Adding this newline passed the CI tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dymurray Ahhh, that makes sense!

if __name__ == '__main__':
main()
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does LGTM, but I'm just going to make sure this still works when creating k8s resources via OpenShift.

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for more tests. thank you!


@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