-
Notifications
You must be signed in to change notification settings - Fork 70
Wrong provider name in answers.conf, exits AtomicApp with readable error #563
Wrong provider name in answers.conf, exits AtomicApp with readable error #563
Conversation
atomicapp/nulecule/lib.py
Outdated
|
|
||
| import logging | ||
|
|
||
| from atomicapp import set_logging |
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.
where is this used?
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.
@surajssd remove unused import :)
|
@rtnpro should we also write a test for this? |
atomicapp/nulecule/lib.py
Outdated
| @@ -1,11 +1,18 @@ | |||
| # -*- coding: utf-8 -*- | |||
| import sys | |||
|
|
|||
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.
Unnecessary new line
|
@surajssd could you have a look at https://travis-ci.org/projectatomic/atomicapp/builds/109825603? I think with the suggested refactor, it should be OK. |
0cd8e76 to
eae57d1
Compare
|
@surajssd Mind adding unittests for |
atomicapp/plugin.py
Outdated
| raise NuleculeException("Invalid Provider - '{}', provided in " | ||
| "answers.conf (choose from 'docker', " | ||
| "'kubernetes', 'openshift', 'marathon')" | ||
| .format(provider_key)) |
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.
If we choose to tell them what options they can use then we should be using the PROVIDERS constant from constants.py and not a hardcoded list.
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.
yes can do that!
0813d76 to
87ed1ad
Compare
atomicapp/plugin.py
Outdated
| return provider | ||
|
|
||
| # importing this on top of file leads to circular import | ||
| from atomicapp.nulecule.exceptions import NuleculeException |
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.
local imports are kind of hacks, and I prefer to avoid them. Let's not reference Nulecule* things in plugin.py at all, because, plugin.py is a dependency for Nulecule* and other things. Does it make sense?
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.
Yes makes sense, but then what exception do I raise here?
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.
So, as I had said earlier, let's raise an exception in nulecule/main.py when provider is None.
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.
No need to raise any exception in plugin.py. It returns None because it's not able to find a provider. Simple, isn't it?
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.
yes makes sense!! :)
87ed1ad to
aa9414f
Compare
|
@surajssd One last thing, could you add a unittest for |
f8cbf5d to
ea12f35
Compare
|
LGTM 👍 @dustymabe shall we merge it in to |
|
@rtnpro I trust you. :) - merge away. |
|
I think we need to do a better job of commenting the tests. Without knowing mock I should be able to read through the code and get a high level understanding of what it is testing. |
|
Yes sure, its harder for somebody not knowing mock to understand what is actually going on! |
|
@surajssd - rebase on upstream master so we can merge.. bonus points if you comment the tests :) |
When provider name in answers.conf is wrong then AtomicApp fails with stack-trace and no error output which is user understandable. This happened because there was no check for the condition if given provider_key does not match with any of the providers that are supported for now. Fixes Issue projectatomic#562.
ea12f35 to
063a59b
Compare
|
@dustymabe I have added comments, was little confused about what all to include into them, share your views. |
|
@cdrage can you merge this if tests pass and you are satisfied with everything? |
|
Tests pass and code looks good. Thank you for the extensives tests by the way! 💃 |
Wrong provider name in answers.conf, exits AtomicApp with readable error
|
|
When
providername inanswers.confis wrong then AtomicApp fails with stack-trace and no error output which is user understandable. This happened because there was no check for the condition ifgiven
provider_keydoes not match with any of the providers that are supported for now.Fixes Issue #562