MCPcopy Index your code
hub / github.com/coder/coder / searchTerms

Function searchTerms

coderd/searchquery/search.go:644–684  ·  view source on GitHub ↗
(query string, defaultKey func(term string, values url.Values) error)

Source from the content-addressed store, hash-verified

642}
643
644func searchTerms(query string, defaultKey func(term string, values url.Values) error) (url.Values, []codersdk.ValidationError) {
645 searchValues := make(url.Values)
646
647 // Because we do this in 2 passes, we want to maintain quotes on the first
648 // pass. Further splitting occurs on the second pass and quotes will be
649 // dropped.
650 tokens := splitQueryParameterByDelimiter(query, ' ', true)
651 elements := processTokens(tokens)
652 for _, element := range elements {
653 if strings.HasPrefix(element, ":") || strings.HasSuffix(element, ":") {
654 return nil, []codersdk.ValidationError{
655 {
656 Field: "q",
657 Detail: fmt.Sprintf("Query element %q cannot start or end with ':'", element),
658 },
659 }
660 }
661 parts := splitQueryParameterByDelimiter(element, ':', false)
662 switch len(parts) {
663 case 1:
664 // No key:value pair. Use default behavior.
665 err := defaultKey(element, searchValues)
666 if err != nil {
667 return nil, []codersdk.ValidationError{
668 {Field: "q", Detail: err.Error()},
669 }
670 }
671 case 2:
672 searchValues.Add(strings.ToLower(parts[0]), parts[1])
673 default:
674 return nil, []codersdk.ValidationError{
675 {
676 Field: "q",
677 Detail: fmt.Sprintf("Query element %q can only contain 1 ':'", element),
678 },
679 }
680 }
681 }
682
683 return searchValues, nil
684}
685
686func parseOrganization(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string) uuid.UUID {
687 return httpapi.ParseCustom(parser, vals, uuid.Nil, queryParam, func(v string) (uuid.UUID, error) {

Callers 12

AuditLogsFunction · 0.85
ConnectionLogsFunction · 0.85
UsersFunction · 0.85
MembersFunction · 0.85
WorkspacesFunction · 0.85
TemplatesFunction · 0.85
AIBridgeInterceptionsFunction · 0.85
AIBridgeSessionsFunction · 0.85
AIBridgeModelsFunction · 0.85
AIBridgeClientsFunction · 0.85
TasksFunction · 0.85
ChatsFunction · 0.85

Calls 4

processTokensFunction · 0.85
AddMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected