func (s Service) discoverPod(name cntspec.ACFullname) []cntspec.ACFullname { logAci := s.log.WithField("pod", name) app, err := discovery.NewAppFromString(name.String()) if app.Labels["os"] == "" { app.Labels["os"] = "linux" } if app.Labels["arch"] == "" { app.Labels["arch"] = "amd64" } endpoint, _, err := discovery.DiscoverEndpoints(*app, false) if err != nil { logAci.WithError(err).Fatal("pod discovery failed") } url := endpoint.ACIEndpoints[0].ACI url = strings.Replace(url, "=aci", "=pod", 1) // TODO this is nexus specific logUrl := logAci.WithField("url", url) response, err := http.Get(url) if err != nil { logUrl.WithError(err).Fatal("Cannot get pod manifest content") return nil } else { if response.StatusCode != 200 { logUrl.WithField("status_code", response.StatusCode).WithField("status_message", response.Status). Fatal("Receive response error for discovery") } defer response.Body.Close() content, err := ioutil.ReadAll(response.Body) if err != nil { logUrl.WithError(err).Fatal("Cannot read pod manifest content") } tmpMap := make(map[string][]cntspec.ACFullname, 1) if err := s.podManifestToMap(tmpMap, content); err != nil { logUrl.WithError(err).Fatal("Cannot read pod content") } acis := tmpMap[name.Name()] if acis == nil { logUrl.Fatal("Discovered pod name does not match requested") } return acis } }