code: func formatEndpoints(endpoints *corev1.Endpoints, ports sets.String) string {
  	if len(endpoints.Subsets) == 0 {
  		return "<none>"
  	}
  	list := []string{}
  	max := 3
  	more := false
  	count := 0
  	for i := range endpoints.Subsets {
  		ss := &endpoints.Subsets[i]
  		if len(ss.Ports) == 0 {
  			// It's possible to have headless services with no ports.
  			for i := range ss.Addresses {
  				if len(list) == max {
  					more = true
  				}
  				if !more {
  					list = append(list, ss.Addresses[i].IP)
  				}
  				count++
  			}
  		} else {
  			// "Normal" services with ports defined.
  			for i := range ss.Ports {
  				port := &ss.Ports[i]
  				if ports == nil || ports.Has(port.Name) {
  					for i := range ss.Addresses {
  						if len(list) == max {
  							more = true
  						}
  						addr := &ss.Addresses[i]
  						if !more {
  							hostPort := net.JoinHostPort(addr.IP, strconv.Itoa(int(port.Port)))
  							list = append(list, hostPort)
  						}
  						count++
  					}
  				}
  			}
  		}
  	}
  	ret := strings.Join(list, ",")
  	if more {
  		return fmt.Sprintf("%s + %d more...", ret, count-max)
  	}
  	return ret
  }
docs: // Pass ports=nil for all ports.