Skip to content

Commit

Permalink
feat: Remove 127.0.0.1 from start and restart message, place in one f…
Browse files Browse the repository at this point in the history
…unction, fixes ddev#6500 (ddev#6595) [skip ci]

Co-authored-by: Stanislav Zhuk <[email protected]>
  • Loading branch information
davearch and stasadev authored Oct 10, 2024
1 parent 44c6293 commit 8d829bd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
8 changes: 1 addition & 7 deletions cmd/ddev/cmd/restart.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
},
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/ddev/cmd/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package cmd

import (
"fmt"
"github.com/ddev/ddev/pkg/globalconfig"
"os"
"slices"
"strings"
"testing"

Expand All @@ -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()
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/ddev/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 11 additions & 1 deletion cmd/ddev/cmd/start_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cmd

import (
"github.com/ddev/ddev/pkg/globalconfig"
"github.com/stretchr/testify/require"
"slices"
"testing"

"os"
Expand Down Expand Up @@ -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)
}
}
}

0 comments on commit 8d829bd

Please sign in to comment.