// convertPodNamedPortToNumber converts named ports into port numbers
// It returns an error when a named port can't be found in the pod containers.
convertPodNamedPortToNumber converts named ports into port numbers
It returns an error when a named port can't be found in the pod containers.
// convertPodNamedPortToNumber converts named ports into port numbers // It returns an error when a named port can ' t be found in the pod containers .
func convertPodNamedPortToNumber(port string, pod corev1.Pod) (string, error) {
	localPort, remotePort := splitPort(port)
	containerPortStr := remotePort
	_, err := strconv.Atoi(remotePort)
	if err != nil {
		containerPort, err := util.LookupContainerPortNumberByName(pod, remotePort)
		if err != nil {
			return "", err
		}
		containerPortStr = strconv.Itoa(int(containerPort))
	}
	if localPort != remotePort {
		return fmt.Sprintf("%s:%s", localPort, containerPortStr), nil
	}
	return containerPortStr, nil
}
func convertPodNamedPortToNumber ( port string , pod corev1 . Pod ) ( string , error ) { localPort , remotePort := splitPort ( port ) containerPortStr := remotePort _ , err := strconv . Atoi ( remotePort ) if err != nil { containerPort , err := util . LookupContainerPortNumberByName ( pod , remotePort ) if err != nil { return " " , err } containerPortStr = strconv . Itoa ( int ( containerPort ) ) } if localPort != remotePort { return fmt . Sprintf ( " " , localPort , containerPortStr ) , nil } return containerPortStr , nil }
convertPodNamedPortToNumber converts named ports into port numbers
It returns an error when a named port can't be found in the pod containers.
convertPodNamedPortToNumber converts named ports into port numbers It returns an error when a named port can ' t be found in the pod containers .