github.com/cilium/cilium@v1.16.2/pkg/hubble/metrics/api/options.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Hubble 3 4 package api 5 6 import ( 7 "strings" 8 ) 9 10 // Options are options provided to a metric handler 11 type Options map[string]string 12 13 // ParseOptions parses a metric handler option string into a options map 14 func ParseOptions(s string) (options Options) { 15 options = Options{} 16 17 for _, option := range strings.Split(s, ";") { 18 if option == "" { 19 continue 20 } 21 22 kv := strings.SplitN(option, "=", 2) 23 if len(kv) == 2 { 24 options[kv[0]] = kv[1] 25 } else { 26 options[kv[0]] = "" 27 } 28 } 29 30 return 31 }