This repository was archived by the owner on Jan 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Add checking if resource is OpenShift specific to properly create OpenShift artifacts #802
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -540,5 +540,6 @@ def main(): | |
| cli = CLI() | ||
| cli.run() | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 {} | ||
|
|
@@ -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'] | ||
|
|
@@ -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") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random newline added?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!