func dedupPorts()

in pkg/resolvers/endpoints.go [484:504]


func dedupPorts(policyPorts []policyinfo.Port) []policyinfo.Port {
	ports := make(map[string]policyinfo.Port)
	for _, port := range policyPorts {
		prot, p, ep := "", "", ""
		if port.Protocol != nil {
			prot = string(*port.Protocol)
		}
		if port.Port != nil {
			p = strconv.FormatInt(int64(*port.Port), 10)
		}
		if port.EndPort != nil {
			ep = strconv.FormatInt(int64(*port.EndPort), 10)
		}

		ports[fmt.Sprintf("%s@%s@%s", prot, p, ep)] = port
	}
	if len(ports) > 0 {
		return maps.Values(ports)
	}
	return nil
}