check reservation before accessing instance

Docker-DCO-1.1-Signed-off-by: Aaron Feng aaron.feng@gmail.com (github: aaronfeng)
This commit is contained in:
Aaron Feng 2014-06-17 12:50:09 -04:00
parent b1fb5ace1b
commit e91e665cc8
1 changed files with 3 additions and 0 deletions

View File

@ -172,6 +172,9 @@ func (c *ec2Client) findInstance() (instance *ec2.Instance, err error) {
if resp, err := c.ec2Conn.Instances([]string{}, filter); err != nil {
return nil, err
} else {
if resp.Reservations == nil {
return nil, nil
}
return &resp.Reservations[0].Instances[0], nil
}
}