(instances *charttpl.Instances)
| 343 | } |
| 344 | |
| 345 | func compileInstanceByLabels(instances *charttpl.Instances) ([]program.InstanceLabelSelector, error) { |
| 346 | if instances == nil { |
| 347 | return nil, nil |
| 348 | } |
| 349 | out := make([]program.InstanceLabelSelector, 0, len(instances.ByLabels)) |
| 350 | for _, token := range instances.ByLabels { |
| 351 | t := strings.TrimSpace(token) |
| 352 | switch { |
| 353 | case t == "*": |
| 354 | out = append(out, program.InstanceLabelSelector{IncludeAll: true}) |
| 355 | case strings.HasPrefix(t, "!"): |
| 356 | key := strings.TrimSpace(strings.TrimPrefix(t, "!")) |
| 357 | if key == "" { |
| 358 | return nil, fmt.Errorf("exclude token must include label key") |
| 359 | } |
| 360 | out = append(out, program.InstanceLabelSelector{Exclude: true, Key: key}) |
| 361 | default: |
| 362 | out = append(out, program.InstanceLabelSelector{Key: t}) |
| 363 | } |
| 364 | } |
| 365 | return out, nil |
| 366 | } |
| 367 | |
| 368 | func metricKindsFromNames(names []string) []string { |
| 369 | seen := make(map[string]struct{}) |
no test coverage detected
searching dependent graphs…