(vals []string, expectedNumberOfValues int)
| 164 | } |
| 165 | |
| 166 | func validateLabelValues(vals []string, expectedNumberOfValues int) error { |
| 167 | if len(vals) != expectedNumberOfValues { |
| 168 | // The call below makes vals escape, copy them to avoid that. |
| 169 | vals := append([]string(nil), vals...) |
| 170 | return fmt.Errorf( |
| 171 | "%w: expected %d label values but got %d in %#v", |
| 172 | errInconsistentCardinality, expectedNumberOfValues, |
| 173 | len(vals), vals, |
| 174 | ) |
| 175 | } |
| 176 | |
| 177 | for _, val := range vals { |
| 178 | if !utf8.ValidString(val) { |
| 179 | return fmt.Errorf("label value %q is not valid UTF-8", val) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | func checkLabelName(l string) bool { |
| 187 | //nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme. |
no outgoing calls