version.Current must die
William Reade
william.reade at canonical.com
Fri Mar 22 09:34:19 UTC 2013
On Fri, 2013-03-22 at 10:30 +1300, Tim Penhey wrote:
> version.Current represents the current release and architecture of the
> machine that the code is running on, and probably not what we want at all.
The current non-test uses are as follows:
* cmd/juju/upgradejuju.go (makes no sense to me)
* cmd/jujud/bootstrap.go (just the series, but needs to be that of the
current machine)
* cmd/jujud/upgrade.go (all legitimate AFAICT)
* cmd/version.go (legitimate)
* environs/* (all illegitimate, I think)
* worker/deployer/simple.go (legitimate, I think)
...so I don't think it's as simple as "must die", but I'd agree with "is
very frequently used inappropriately". (FWIW, most test uses are
completely illegitimate.)
> I propose we have a version.Default() that returns a new instance of a
> version.Binary that represents the current supported LTS (currently
> "precise") on a 64bit OS ("amd64").
I am pretty sure that the default-series (which I agree should default
to "precise") and agent-version (see below) are sufficient here: the
only time it's reasonable to look up tools is when you already know what
arch you'll be running on.
Agent-version, I think, needs to be thought through more carefully wrt
how it's set at bootstrap time; but if we have sane behaviour on
bootstrap, and subsequently use it whenever we're looking for tools, I
think we're good.
> By having a defined versions.Default(), we are testing the same code on
> everyone's machine.
We certainly shouldn't be using version.Current except in a very few
places in the tests, but I'm not sure a version.Default() solves many
problems. I'm probably being dense, but please expand a little?
Cheers
William
More information about the Juju-dev
mailing list