Skip to content

Commit

Permalink
fix: ddev config should not change unspecified options
Browse files Browse the repository at this point in the history
  • Loading branch information
stasadev authored and rfay committed Feb 25, 2024
1 parent d9d922f commit af3d18a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/ddev/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func handleMainConfigArgs(cmd *cobra.Command, _ []string, app *ddevapp.DdevApp)
switch {
case app.Type != nodeps.AppTypeNone && projectTypeArg == "" && detectedApptype != app.Type: // apptype was not passed, but we found an app of a different type
util.Warning("A project of type '%s' was found in %s, but the project is configured with type '%s'", detectedApptype, fullPath, app.Type)
fallthrough
break
default:
if projectTypeArg == "" {
projectTypeArg = detectedApptype
Expand Down
23 changes: 12 additions & 11 deletions cmd/ddev/cmd/config_test.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package cmd

import (
"strconv"
"testing"

"github.com/ddev/ddev/pkg/fileutil"
"github.com/ddev/ddev/pkg/globalconfig"
"github.com/ddev/ddev/pkg/nodeps"
"github.com/stretchr/testify/require"

"fmt"
"os"
"path/filepath"

"strconv"
"strings"

"fmt"
"testing"

"github.com/ddev/ddev/pkg/ddevapp"
"github.com/ddev/ddev/pkg/exec"
"github.com/ddev/ddev/pkg/fileutil"
"github.com/ddev/ddev/pkg/globalconfig"
"github.com/ddev/ddev/pkg/nodeps"
"github.com/ddev/ddev/pkg/testcommon"
asrt "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -230,6 +226,11 @@ func TestConfigSetValues(t *testing.T) {
out, err := exec.RunHostCommand(DdevBin, args...)
assert.NoError(err, "error running ddev %v: %v, output=%s", args, err, out)

// The second run of the config should not change the unspecified options,
// using the auto option here should not change the config at all
out, err = exec.RunHostCommand(DdevBin, "config", "--auto")
assert.NoError(err, "error running ddev config --auto: %s", out)

configFile := filepath.Join(tmpDir, ".ddev", "config.yaml")
configContents, err := os.ReadFile(configFile)
if err != nil {
Expand Down

0 comments on commit af3d18a

Please sign in to comment.