func()

in sharedlibraries/gce/gce.go [208:230]


func (g *GCE) GetURIForIP(project, ip, region, subnetwork string) (string, error) {
	log.Logger.Debugw("GetURIForIP", "project", project, "ip", ip, "region", region, "subnetwork", subnetwork)
	addr, _ := g.GetAddressByIP(project, "", subnetwork, ip)
	if addr != nil {
		return addr.SelfLink, nil
	}
	inst, _ := g.GetInstanceByIP(project, ip)
	if inst != nil {
		return inst.SelfLink, nil
	}

	fwr, _ := g.GetForwardingRuleByIP(project, ip)
	if fwr != nil {
		return fwr.SelfLink, nil
	}

	fs, err := g.GetFilestoreByIP(project, "-", ip)
	if fs != nil && len(fs.Instances) > 0 {
		fsURI := strings.Replace(fs.Instances[0].Name, "/instances/", "/filestores/", 1)
		return fsURI, nil
	}
	return "", errors.Errorf("error locating object by IP: %v", err)
}