func (h *IPPortIndexer) GetMetadata(pod *Pod) []MetadataIndex {
	commonMeta := h.genMeta.GenerateMetaData(pod)
	hostPorts := h.GetIndexes(pod)
	var metadata []MetadataIndex

	if pod.Status.PodIP == "" {
		return metadata
	}

	// Add pod IP
	metadata = append(metadata, MetadataIndex{
		Index: pod.Status.PodIP,
		Data:  commonMeta,
	})

	for i := 1; i < len(hostPorts); i++ {
		dobreak := false
		containerMeta := commonMeta.Clone()
		for _, container := range pod.Spec.Containers {
			ports := container.Ports

			for _, port := range ports {
				if port.ContainerPort == int64(0) {
					continue
				}
				if strings.Index(hostPorts[i], fmt.Sprintf("%s:%d", pod.Status.PodIP, port.ContainerPort)) != -1 {
					containerMeta["container"] = common.MapStr{
						"name": container.Name,
					}
					dobreak = true
					break
				}
			}

			if dobreak {
				break
			}
		}

		metadata = append(metadata, MetadataIndex{
			Index: hostPorts[i],
			Data:  containerMeta,
		})
	}

	return metadata
}
// GetMetadata returns metadata for the given pod, if it matches the index
GetMetadata returns metadata for the given pod, if it matches the index
// GetMetadata returns metadata for the given pod if it matches the index
func (h *IPPortIndexer) GetMetadata(pod *Pod) []MetadataIndex {
	commonMeta := h.genMeta.GenerateMetaData(pod)
	hostPorts := h.GetIndexes(pod)
	var metadata []MetadataIndex
	if pod.Status.PodIP == "" {
		return metadata
	}
	metadata = append(metadata, MetadataIndex{
		Index: pod.Status.PodIP,
		Data:  commonMeta,
	})
	for i := 1; i < len(hostPorts); i++ {
		dobreak := false
		containerMeta := commonMeta.Clone()
		for _, container := range pod.Spec.Containers {
			ports := container.Ports
			for _, port := range ports {
				if port.ContainerPort == int64(0) {
					continue
				}
				if strings.Index(hostPorts[i], fmt.Sprintf("%s:%d", pod.Status.PodIP, port.ContainerPort)) != -1 {
					containerMeta["container"] = common.MapStr{
						"name": container.Name,
					}
					dobreak = true
					break
				}
			}
			if dobreak {
				break
			}
		}
		metadata = append(metadata, MetadataIndex{
			Index: hostPorts[i],
			Data:  containerMeta,
		})
	}
	return metadata
}
func ( h * IPPortIndexer ) GetMetadata ( pod * Pod ) [ ] MetadataIndex { commonMeta := h . genMeta . GenerateMetaData ( pod ) hostPorts := h . GetIndexes ( pod ) var metadata [ ] MetadataIndex if pod . Status . PodIP == " " { return metadata } metadata = append ( metadata , MetadataIndex { Index : pod . Status . PodIP , Data : commonMeta , } ) for i := 1 ; i < len ( hostPorts ) ; i ++ { dobreak := false containerMeta := commonMeta . Clone ( ) for _ , container := range pod . Spec . Containers { ports := container . Ports for _ , port := range ports { if port . ContainerPort == int64 ( 0 ) { continue } if strings . Index ( hostPorts [ i ] , fmt . Sprintf ( " " , pod . Status . PodIP , port . ContainerPort ) ) != - 1 { containerMeta [ " " ] = common . MapStr { " " : container . Name , } dobreak = true break } } if dobreak { break } } metadata = append ( metadata , MetadataIndex { Index : hostPorts [ i ] , Data : containerMeta , } ) } return metadata }
GetMetadata returns metadata for the given pod, if it matches the index
GetMetadata returns metadata for the given pod if it matches the index
// Add pod IP