in sharedlibraries/gce/gce.go [72:88]
func (g *GCE) GetInstanceByIP(project, ip string) (*compute.Instance, error) {
list, err := g.service.Instances.AggregatedList(project).Do()
if err != nil {
return nil, fmt.Errorf("error retrieving aggregated instance list: %s", err)
}
for _, l := range list.Items {
for _, instance := range l.Instances {
for _, n := range instance.NetworkInterfaces {
if n.NetworkIP == ip {
return instance, nil
}
}
}
}
return nil, errors.Errorf("no instance with IP %s found", ip)
}