MCPcopy Index your code
hub / github.com/ddev/ddev / GetWebContainerDirectHTTPSPort

Method GetWebContainerDirectHTTPSPort

pkg/ddevapp/ddevapp.go:3592–3619  ·  view source on GitHub ↗

GetWebContainerDirectHTTPSPort returns the direct-access public tcp port for https

()

Source from the content-addressed store, hash-verified

3590
3591// GetWebContainerDirectHTTPSPort returns the direct-access public tcp port for https
3592func (app *DdevApp) GetWebContainerDirectHTTPSPort() (int, error) {
3593 webContainer, err := app.FindContainerByType("web")
3594 if err != nil || webContainer == nil {
3595 return -1, fmt.Errorf("unable to find web container for app: %s, err %v", app.Name, err)
3596 }
3597
3598 // Try getting the published port for the standard HTTP port first
3599 port, err := app.GetPublishedPortForPrivatePort("web", 443)
3600 if err == nil && port != 0 {
3601 return port, nil
3602 }
3603
3604 // If standard method fails and it's a generic webserver with extra exposed ports
3605 if app.WebserverType == nodeps.WebserverGeneric && len(app.WebExtraExposedPorts) > 0 {
3606 for _, extraPort := range app.WebExtraExposedPorts {
3607 // Check only ports mapped to HTTPS (port 443)
3608 if extraPort.HTTPSPort == 443 {
3609 containerPort := uint16(extraPort.WebContainerPort)
3610 publishedPort, err := app.GetPublishedPortForPrivatePort("web", containerPort)
3611 if err == nil && containerPort != 0 {
3612 return publishedPort, nil
3613 }
3614 }
3615 }
3616 }
3617
3618 return -1, fmt.Errorf("no public https port found for private port 443")
3619}
3620
3621// HostName returns the hostname of a given application.
3622func (app *DdevApp) HostName() string {

Callers 1

Calls 3

FindContainerByTypeMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected