func (l *LabelsAllowList) Set(value string) error {
	const EOF = -1
	var (
		m            = make(map[string][]string, len(*l))
		previous     rune
		next         rune
		firstWordPos int
		name         string
	)
	firstWordPos = 0
	for i, v := range value {
		if i+1 == len(value) {
			next = EOF
		} else {
			next = []rune(value)[i+1]
		}
		if i-1 >= 0 {
			previous = []rune(value)[i-1]
		} else {
			previous = v
		}
		switch v {
		case '=':
			if previous == ',' || next != '[' {
				return errLabelsAllowListFormat
			}
			name = strings.TrimSpace(string(([]rune(value)[firstWordPos:i])))
			m[name] = []string{}
			firstWordPos = i + 1
		case '[':
			if previous != '=' {
				return errLabelsAllowListFormat
			}
			firstWordPos = i + 1
		case ']':
			if next != EOF && next != ',' {
				return errLabelsAllowListFormat
			}
			if previous != '[' {
				m[name] = append(m[name], strings.TrimSpace(string(([]rune(value)[firstWordPos:i]))))
			}
			firstWordPos = i + 1
		case ',':
			if previous == v || next == EOF || next == ']' {
				return errLabelsAllowListFormat
			}
			if previous != ']' {
				m[name] = append(m[name], strings.TrimSpace(string(([]rune(value)[firstWordPos:i]))))
			}
			firstWordPos = i + 1
		}
	}
	*l = m
	return nil
}
Set converts a comma-separated string of resources and their allowed Kubernetes labels and appends to the LabelsAllowList.
Value is in the following format:
resource=[k8s-label-name,another-k8s-label],another-resource[k8s-label]
Example: pods=[app.kubernetes.io/component,app],resource=[blah]
package options
import (
	"errors"
	"sort"
	"strings"
	"k8s.io/apimachinery/pkg/fields"
	"k8s.io/klog/v2"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var errLabelsAllowListFormat = errors.New("invalid format, metric=[label1,label2,labeln...],metricN=[]")
type MetricSet map[string]struct{}
func (ms *MetricSet) String() string {
	s := *ms
	ss := s.asSlice()
	sort.Strings(ss)
	return strings.Join(ss, ",")
}
func (ms *MetricSet) Set(value string) error {
	s := *ms
	metrics := strings.Split(value, ",")
	for _, metric := range metrics {
		metric = strings.TrimSpace(metric)
		if len(metric) != 0 {
			s[metric] = struct{}{}
		}
	}
	return nil
}
func (ms MetricSet) asSlice() []string {
	metrics := make([]string, 0, len(ms))
	for metric := range ms {
		metrics = append(metrics, metric)
	}
	return metrics
}
func (ms *MetricSet) Type() string {
	return "string"
}
type ResourceSet map[string]struct{}
func (r *ResourceSet) String() string {
	s := *r
	ss := s.AsSlice()
	sort.Strings(ss)
	return strings.Join(ss, ",")
}
func (r *ResourceSet) Set(value string) error {
	s := *r
	cols := strings.Split(value, ",")
	for _, col := range cols {
		col = strings.TrimSpace(col)
		if len(col) != 0 {
			s[col] = struct{}{}
		}
	}
	return nil
}
func (r ResourceSet) AsSlice() []string {
	cols := make([]string, 0, len(r))
	for col := range r {
		cols = append(cols, col)
	}
	return cols
}
func (r *ResourceSet) Type() string {
	return "string"
}
type NamespaceList []string
func (n *NamespaceList) String() string {
	return strings.Join(*n, ",")
}
func (n *NamespaceList) IsAllNamespaces() bool {
	return len(*n) == 1 && (*n)[0] == metav1.NamespaceAll
}
func (n *NamespaceList) Set(value string) error {
	splitNamespaces := strings.Split(value, ",")
	for _, ns := range splitNamespaces {
		ns = strings.TrimSpace(ns)
		if len(ns) != 0 {
			*n = append(*n, ns)
		}
	}
	return nil
}
func (n *NamespaceList) GetNamespaces() NamespaceList {
	ns := *n
	if len(*n) == 0 {
		klog.Info("Using all namespace")
		ns = DefaultNamespaces
	} else {
		if n.IsAllNamespaces() {
			klog.Info("Using all namespace")
		} else {
			klog.Infof("Using %s namespaces", ns)
		}
	}
	return ns
}
func (n *NamespaceList) GetExcludeNSFieldSelector(nsDenylist []string) string {
	if len(nsDenylist) == 0 {
		return ""
	}
	namespaceExcludeSelectors := make([]fields.Selector, len(nsDenylist))
	for i, ns := range nsDenylist {
		selector := fields.OneTermNotEqualSelector("metadata.namespace", ns)
		namespaceExcludeSelectors[i] = selector
	}
	return fields.AndSelectors(namespaceExcludeSelectors...).String()
}
func (n *NamespaceList) Type() string {
	return "string"
}
const LabelWildcard = "*"
type LabelsAllowList map[string][]string