Machine.InstanceId error condition.

David Cheney david.cheney at canonical.com
Wed Jun 20 11:14:07 UTC 2012


Yup. That is another valid option, and has the benefit that we don't need to do a change. 

I'm responding to the TODO from a previous review, but if the prevailing opinion is this is not an issue, I'll move on to something else. 

Dave

On 20/06/2012, at 20:42, roger peppe <roger.peppe at canonical.com> wrote:

> 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