Machine.InstanceId error condition.

roger peppe roger.peppe at canonical.com
Wed Jun 20 10:42:15 UTC 2012


On 20 June 2012 11:02, David Cheney <david.cheney at canonical.com> wrote:
>
>
>
> Begin forwarded message:
>
> From: Dave Cheney <dave at cheney.net>
> Date: 20 June 2012 19:59:54 AEST
> To: juju-dev at lists.ubuntu.com
> Subject: Machine.InstanceId error condition.
>
> Hello,
>
> I'm working on a branch to address the todo surrounding machine.InstanceId
> retuning an error if no Id was set. Given the frequency of this condition
> (at least 50% of the code paths expect the instance id to be _not_ set) I am
> considering this signature.
>
> id, set, err := machine.InstanceId()
>
> Where set is a Boolean, and error is only non nil when something error
> worthy happened.
>
> In other words, id should not be an empty string unless set is false or err
> is non nil.

I'm not keen on this. We've already got a perfectly good test for whether
the instance id is set: id != "". AFAICS set is true iff id != "".

To be honest, I'd be happy if InstanceId returned "", nil when the
instance id had not been set - it's the zero value.

But I think we might have started off like that and moved
towards returning an error.



More information about the Juju-dev mailing list