Skip to content

Commit

Permalink
fix: use natural sort for project+database types, fixes ddev#3561 (dd…
Browse files Browse the repository at this point in the history
…ev#6001) [skip ci]
  • Loading branch information
rfay authored Mar 23, 2024
1 parent 52716db commit 0273515
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 9 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/jedib0t/go-pretty/v6 v6.4.9
github.com/joho/godotenv v1.5.1
github.com/manifoldco/promptui v0.9.0
github.com/maruel/natural v1.1.1
github.com/mattn/go-isatty v0.0.20
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.5.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
Expand Down
3 changes: 2 additions & 1 deletion pkg/ddevapp/apptypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ddev/ddev/pkg/nodeps"
"github.com/ddev/ddev/pkg/util"
"github.com/maruel/natural"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -485,7 +486,7 @@ func GetValidAppTypes() []string {
keys := make([]string, 0, len(appTypeMatrix))
for k := range appTypeMatrix {
keys = append(keys, k)
sort.Strings(keys)
sort.Sort(natural.StringSlice(keys))
}
return keys
}
4 changes: 0 additions & 4 deletions pkg/ddevapp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,6 @@ func (app *DdevApp) ValidateConfig() error {
}
}

// if app.Database.Type == nodeps.Postgres && (nodeps.ArrayContainsString([]string{"wordpress", "magento", "magento2"}, app.Type)) {
// return fmt.Errorf("the %s project has a project type %s that does not support PostgreSQL database", app.Name, app.Type)
// }

return nil
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/nodeps/values.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nodeps

import (
"github.com/maruel/natural"
"sort"

"github.com/ddev/ddev/pkg/config/types"
Expand Down Expand Up @@ -136,7 +137,7 @@ func GetValidPHPVersions() []string {
for p := range ValidPHPVersions {
s = append(s, p)
}
sort.Strings(s)
sort.Sort(natural.StringSlice(s))
return s
}

Expand Down Expand Up @@ -197,7 +198,7 @@ func GetValidMariaDBVersions() []string {
for p := range ValidMariaDBVersions {
s = append(s, p)
}
sort.Strings(s)
sort.Sort(natural.StringSlice(s))
return s
}

Expand All @@ -218,7 +219,7 @@ func GetValidMySQLVersions() []string {
for p := range ValidMySQLVersions {
s = append(s, p)
}
sort.Strings(s)
sort.Sort(natural.StringSlice(s))
return s
}

Expand All @@ -229,7 +230,7 @@ func GetValidPostgresVersions() []string {
for p := range ValidPostgresVersions {
s = append(s, p)
}
sort.Strings(s)
sort.Sort(natural.StringSlice(s))
return s
}

Expand Down
201 changes: 201 additions & 0 deletions vendor/github.com/maruel/natural/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions vendor/github.com/maruel/natural/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0273515

Please sign in to comment.