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

Function ValidateAggregationLabels

coderd/agentmetrics/labels.go:22–38  ·  view source on GitHub ↗

ValidateAggregationLabels ensures a given set of labels are valid aggregation labels.

(labels []string)

Source from the content-addressed store, hash-verified

20
21// ValidateAggregationLabels ensures a given set of labels are valid aggregation labels.
22func ValidateAggregationLabels(labels []string) error {
23 acceptable := LabelAll
24
25 seen := make(map[string]any, len(acceptable))
26 for _, label := range acceptable {
27 seen[label] = nil
28 }
29
30 for _, label := range labels {
31 if _, found := seen[label]; !found {
32 return xerrors.Errorf("%q is not a valid aggregation label; only one or more of %q are acceptable",
33 label, strings.Join(acceptable, ", "))
34 }
35 }
36
37 return nil
38}

Callers 2

OptionsMethod · 0.92

Calls 1

ErrorfMethod · 0.45

Tested by 1