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

Alex Kavanagh alex.kavanagh at canonical.com
Fri Apr 14 14:14:02 UTC 2017


On Thu, Apr 13, 2017 at 10:13 PM, Colin Watson <cjwatson at ubuntu.com> wrote:

> 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.
>

Good to know that I'm not totally going out on a limb with this approach!
There was some criticism of leaving is as >, <, etc., the alternatives just
seemed really clunky.  There is the downside that people could miss it, but
there wasn't a reasonable way of stopping people just using a regular
string comparison.  Thanks for the feedback / confirmation!


>
> --
> Colin Watson                                       [cjwatson at ubuntu.com]
>
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/juju
>



-- 
Alex Kavanagh - Software Engineer
Cloud Dev Ops - Solutions & Product Engineering - Canonical Ltd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20170414/5ec56e43/attachment.html>


More information about the Juju mailing list