Multi-series charm authors: new functionality for comparing ubuntu versions

Colin Watson cjwatson at ubuntu.com
Thu Apr 13 21:13:15 UTC 2017


On Thu, Apr 13, 2017 at 09:15:08PM +0100, Alex Kavanagh wrote:
> So instead of:
> 
>     if ubuntu_version > 'trusty':
> 
> We do:
> 
>     cmp_version = CompareHostReleases(ubuntu_version)
>     if cmp_version > 'trusty':
> 
> This version of the code checks that ubuntu_version and 'trusty' strings
> are known releases and makes it easy to fix existing code.  >, <, >=< <=,
> ==, != are all supported.

I have déjà vu: I did exactly the same thing in lp:ubuntu-cdimage in
2012. :-)  I agree that this style makes things pretty nice for calling
code.

The one problem I've had with it is that every so often somebody looks
at a bit of code and says "hey, isn't this going to break after 17.04?"
and then I have to explain that it's actually magically OK, which as
problems go is not really a bad one to have.

-- 
Colin Watson                                       [cjwatson at ubuntu.com]



More information about the Juju mailing list