mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: allow search by build params in workspace search filter (#12694)
* chore: workspace search filter allow search by params * has_param will return all workspaces with the param existance * exact matching
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
@@ -268,18 +269,18 @@ func ParseCustomList[T any](parser *QueryParamParser, vals url.Values, def []T,
|
||||
allTerms = append(allTerms, terms...)
|
||||
}
|
||||
|
||||
var badValues []string
|
||||
var badErrors error
|
||||
var output []T
|
||||
for _, s := range allTerms {
|
||||
good, err := parseFunc(s)
|
||||
if err != nil {
|
||||
badValues = append(badValues, s)
|
||||
badErrors = errors.Join(badErrors, err)
|
||||
continue
|
||||
}
|
||||
output = append(output, good)
|
||||
}
|
||||
if len(badValues) > 0 {
|
||||
return []T{}, xerrors.Errorf("%s", strings.Join(badValues, ","))
|
||||
if badErrors != nil {
|
||||
return []T{}, badErrors
|
||||
}
|
||||
|
||||
return output, nil
|
||||
|
||||
@@ -388,7 +388,7 @@ func TestParseQueryParams(t *testing.T) {
|
||||
Value: "6c8ef17d-5dd8-4b92-bac9-41944f90f237,bogus",
|
||||
Expected: []uuid.UUID{},
|
||||
Default: []uuid.UUID{},
|
||||
ExpectedErrorContains: "bogus",
|
||||
ExpectedErrorContains: "invalid UUID length",
|
||||
},
|
||||
{
|
||||
QueryParam: "multiple_keys",
|
||||
|
||||
Reference in New Issue
Block a user