File: filters.go

package info (click to toggle)
libpod 4.3.1%2Bds1-8%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,252 kB
  • sloc: sh: 4,696; perl: 2,043; python: 1,908; ansic: 1,188; makefile: 848; xml: 89; ruby: 42; awk: 12
file content (19 lines) | stat: -rw-r--r-- 417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package parse

import (
	"fmt"
	"net/url"
	"strings"
)

func FilterArgumentsIntoFilters(filters []string) (url.Values, error) {
	parsedFilters := make(url.Values)
	for _, f := range filters {
		t := strings.SplitN(f, "=", 2)
		if len(t) < 2 {
			return parsedFilters, fmt.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
		}
		parsedFilters.Add(t[0], t[1])
	}
	return parsedFilters, nil
}