TargetPortFromExposeVariable uses a string like HTTP_EXPOSE or HTTPS_EXPOSE, which is a comma-delimited list of colon-delimited port-pairs Given a target port (often "80" or "8025") its job is to get from HTTPS_EXPOSE or HTTP_EXPOSE the related port to be exposed on the router. It returns an empty s
(exposeEnvVar string, targetPort string)
| 749 | // It returns an empty string if the HTTP_EXPOSE/HTTPS_EXPOSE is not |
| 750 | // found or no valid port mapping is found. |
| 751 | func (app *DdevApp) TargetPortFromExposeVariable(exposeEnvVar string, targetPort string) string { |
| 752 | // Get the var |
| 753 | // split it via comma |
| 754 | // split it via colon into a map: rhs is the key, lhs is the value |
| 755 | portMap := make(map[string]string) |
| 756 | items := strings.SplitSeq(exposeEnvVar, ",") |
| 757 | for item := range items { |
| 758 | portPair := strings.Split(item, ":") |
| 759 | if len(portPair) == 2 { |
| 760 | portMap[portPair[1]] = portPair[0] |
| 761 | } |
| 762 | } |
| 763 | if w, ok := portMap[targetPort]; ok { |
| 764 | return w |
| 765 | } |
| 766 | return "" |
| 767 | } |
| 768 | |
| 769 | // GetPrimaryRouterHTTPSPort returns app's primary router https port |
| 770 | // It has to choose from (highest to lowest priority): |
no outgoing calls
no test coverage detected