diff --git a/cmd/ddev/cmd/restart.go b/cmd/ddev/cmd/restart.go index 1f4a36a6bd0..c42ca401e21 100644 --- a/cmd/ddev/cmd/restart.go +++ b/cmd/ddev/cmd/restart.go @@ -1,8 +1,6 @@ package cmd import ( - "strings" - "github.com/ddev/ddev/pkg/ddevapp" "github.com/ddev/ddev/pkg/dockerutil" "github.com/ddev/ddev/pkg/output" @@ -53,11 +51,7 @@ ddev restart --all`, } util.Success("Restarted %s", app.GetName()) - httpURLs, urlList, _ := app.GetAllURLs() - if app.CanUseHTTPOnly() { - urlList = httpURLs - } - util.Success("Your project can be reached at %s", strings.Join(urlList, " ")) + emitReachProjectMessage(app) } }, } diff --git a/cmd/ddev/cmd/restart_test.go b/cmd/ddev/cmd/restart_test.go index 7adf97b3874..a94210fe222 100644 --- a/cmd/ddev/cmd/restart_test.go +++ b/cmd/ddev/cmd/restart_test.go @@ -2,7 +2,9 @@ package cmd import ( "fmt" + "github.com/ddev/ddev/pkg/globalconfig" "os" + "slices" "strings" "testing" @@ -24,12 +26,19 @@ func TestCmdRestart(t *testing.T) { out, err := exec.RunCommand(DdevBin, args) assert.NoError(err) - _, err = ddevapp.GetActiveApp("") + app, err := ddevapp.GetActiveApp("") if err != nil { assert.Fail("Could not find an active DDEV configuration: %v", err) } assert.Contains(string(out), "Your project can be reached at") + switch slices.Contains(globalconfig.DdevGlobalConfig.OmitContainersGlobal, "ddev-router") { + case true: + assert.Contains(string(out), "127.0.0.1") + case false: + assert.NotContains(string(out), "127.0.0.1") + assert.Contains(string(out), app.GetPrimaryURL()) + } cleanup() } diff --git a/cmd/ddev/cmd/start.go b/cmd/ddev/cmd/start.go index 95b170f20e6..814982f7a72 100644 --- a/cmd/ddev/cmd/start.go +++ b/cmd/ddev/cmd/start.go @@ -137,16 +137,16 @@ ddev start --all`, } util.Success("Successfully started %s", project.GetName()) - httpURLs, httpsURLs, _ := project.GetAllURLs() - if project.CanUseHTTPOnly() { - httpsURLs = httpURLs - } - util.Success("Project can be reached at %s", strings.Join(httpsURLs, " ")) + emitReachProjectMessage(project) } amplitude.CheckSetUp() }, } +func emitReachProjectMessage(project *ddevapp.DdevApp) { + util.Success("Your project can be reached at %s\nSee 'ddev describe' for alternate URLs.", project.GetPrimaryURL()) +} + func init() { StartCmd.Flags().BoolVarP(&startAll, "all", "a", false, "Start all projects") StartCmd.Flags().BoolP("skip-confirmation", "y", false, "Skip any confirmation steps") diff --git a/cmd/ddev/cmd/start_test.go b/cmd/ddev/cmd/start_test.go index f66f1c86bdd..fdb7afd5bf2 100644 --- a/cmd/ddev/cmd/start_test.go +++ b/cmd/ddev/cmd/start_test.go @@ -1,7 +1,9 @@ package cmd import ( + "github.com/ddev/ddev/pkg/globalconfig" "github.com/stretchr/testify/require" + "slices" "testing" "os" @@ -44,11 +46,19 @@ func TestCmdStart(t *testing.T) { out, err = exec.RunCommand(DdevBin, startMultipleArgs) assert.NoError(err, "ddev start with multiple project names should have succeeded, but failed, err: %v, output %s", err, out) testcommon.CheckGoroutineOutput(t, out) - + // If we omit the router, we should see the 127.0.0.1 URL. + // Whether we have the router or not is not up to us, since it is omitted on gitpod and codespaces. + if slices.Contains(globalconfig.DdevGlobalConfig.OmitContainersGlobal, "ddev-router") { + // Assert that the output contains the 127.0.0.1 URL + assert.Contains(out, "127.0.0.1", "The output should contain the 127.0.0.1 URL, but it does not: %s", out) + } // Confirm all sites are running for _, app := range apps { status, statusDesc := app.SiteStatus() assert.Equal(ddevapp.SiteRunning, status, "All sites should be running, but project=%s status=%s statusDesc=%s", app.GetName(), status, statusDesc) assert.Equal(ddevapp.SiteRunning, statusDesc, `The status description should be "running", but project %s status is: %s`, app.GetName(), statusDesc) + if len(globalconfig.DdevGlobalConfig.OmitContainersGlobal) == 0 { + assert.Contains(out, app.GetPrimaryURL(), "The output should contain the primary URL, but it does not: %s", out) + } } }