Skip to content

Commit

Permalink
fix: improve ddev describe output for HTTP only, fixes ddev#6661 (d…
Browse files Browse the repository at this point in the history
…dev#6662) [skip ci]
  • Loading branch information
stasadev authored Oct 29, 2024
1 parent ac97e92 commit 7c942f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions cmd/ddev/cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func renderAppDescribe(app *ddevapp.DdevApp, desc map[string]interface{}) (strin
switch {
// Normal case, using ddev-router based URLs
case !ddevapp.IsRouterDisabled(app):
if httpsURL, ok := v["https_url"]; ok {
if httpsURL, ok := v["https_url"]; ok && !app.CanUseHTTPOnly() {
urlPortParts = append(urlPortParts, httpsURL)
} else if httpURL, ok = v["http_url"]; ok {
urlPortParts = append(urlPortParts, httpURL)
Expand Down Expand Up @@ -184,14 +184,18 @@ func renderAppDescribe(app *ddevapp.DdevApp, desc map[string]interface{}) (strin
if _, ok := desc["mailpit_url"]; ok {
mailpitURL = desc["mailpit_url"].(string)
}
if _, ok := desc["mailpit_https_url"]; ok {
if _, ok := desc["mailpit_https_url"]; ok && !app.CanUseHTTPOnly() {
mailpitURL = desc["mailpit_https_url"].(string)
}
t.AppendRow(table.Row{"Mailpit", "", fmt.Sprintf("Mailpit: %s\nLaunch: ddev mailpit", mailpitURL)})

//WebExtraExposedPorts stanza
for _, extraPort := range app.WebExtraExposedPorts {
t.AppendRow(table.Row{extraPort.Name, "", fmt.Sprintf("InDocker: localhost:%d https://%s:%d http://%s:%d", extraPort.WebContainerPort, app.GetHostname(), extraPort.HTTPSPort, app.GetHostname(), extraPort.HTTPPort)})
if app.CanUseHTTPOnly() {
t.AppendRow(table.Row{extraPort.Name, "", fmt.Sprintf("http://%s:%d\nInDocker: web:%d", app.GetHostname(), extraPort.HTTPPort, extraPort.WebContainerPort)})
} else {
t.AppendRow(table.Row{extraPort.Name, "", fmt.Sprintf("https://%s:%d\nInDocker: web:%d", app.GetHostname(), extraPort.HTTPSPort, extraPort.WebContainerPort)})
}
}

// All URLs stanza
Expand Down
11 changes: 8 additions & 3 deletions pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -306,7 +307,9 @@ func (app *DdevApp) Describe(short bool) (map[string]interface{}, error) {
services[shortName]["short_name"] = shortName
var ports []string
for pk := range c.Config.ExposedPorts {
ports = append(ports, pk.Port())
if !slices.Contains(ports, pk.Port()) {
ports = append(ports, pk.Port())
}
}
services[shortName]["exposed_ports"] = strings.Join(ports, ",")
var hostPorts []string
Expand Down Expand Up @@ -2937,11 +2940,13 @@ func (app *DdevApp) GetAllURLs() (httpURLs []string, httpsURLs []string, allURLs
httpsPort = ":" + app.GetRouterHTTPSPort()
}

httpsURLs = append(httpsURLs, "https://"+name+httpsPort)
if !app.CanUseHTTPOnly() {
httpsURLs = append(httpsURLs, "https://"+name+httpsPort)
}
httpURLs = append(httpURLs, "http://"+name+httpPort)
}

if !IsRouterDisabled(app) {
if !IsRouterDisabled(app) && !app.CanUseHTTPOnly() {
httpsURLs = append(httpsURLs, app.GetWebContainerDirectHTTPSURL())
}
httpURLs = append(httpURLs, app.GetWebContainerDirectHTTPURL())
Expand Down

0 comments on commit 7c942f7

Please sign in to comment.