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
Turn all States into string values instead of ints #624
Conversation
Thanks. We should just wait with merging this until we decide when to include it in a release since it's a breaking change if people used integers directly. I'm fine with including it in 0.20.0 (next "major" release), but we also need to update documentation (upgrade notes) to reflect this change. |
ERROR = 7 | ||
PAUSED = 8 | ||
RUNNING = "running" | ||
REBOOTING = "rebooting" |
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.
Minor style thing - for consistency, please use single quotes around simple strings :)
6518c92
to
0428067
Compare
So I added tests for all the objects that have strings as values now. All tests pass. @Kami: I'd like for this to go into 0.20. Do you think that is still possible? |
Also, I think the changes involved are minimal. I cannot imagine a use case where you would actually use the integers in normal code. I think everyone involved either used |
|
||
|
||
class StorageVolumeState(object): | ||
RUNNING = 'running' |
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.
Are we ok with this behavior change? The NodeState.tostring(node.state)
values previously were all-caps, now they're all lower-case. I know this means my team's codebase will require changes to keep existing behavior. Could we make Type.tostring
return value.upper()
?
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.
Ah! That is true. Let me add that test. We should've had tests for this stuff all along
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.
Done
Thanks @allardhoeve - lgtm |
734ae6d
to
b2f17f7
Compare
I added docs for 0.20 |
- Let all types derive from Type - Turn all type attributes into strings - Keep things backwards-compatible by having - tostring - fromstring - Add tests for tostring, fromstring closes apache#624 Signed-off-by: Allard Hoeve <allardhoeve@gmail.com>
7c6fce3
to
bef1f94
Compare
* All NodeState, StorageVolumeState, VolumeSnapshotState and Provider attributes | ||
are now strings instead of integers. | ||
|
||
If you are using the ``tostring`` and ``fromstring`` methods of NodeState, |
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.
It would also be good to note that you are affected if you directly store the enum value in the database (integer) - I know some users who do that.
For that scenario this is a backward incompatible change. We don't have any automatic migration path for it - users need to handle that in their code - so for users who do that it's quite an invasive change.
@Kami
Luckily, most tests already used the constants. I found a couple sloppy drivers, especially the ProfitBricks driver, which uses NodeState for everything, including Volumes and Snapshots. Maybe we fix that, maybe we leave it. It doesn't really matter.