mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-16 00:41:24 +01:00
24 lines
585 B
Go
24 lines
585 B
Go
package kubernetes
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// GetLabels returns labels for the given k8s role and the given cfg.
|
|
func GetLabels(cfg *APIConfig, role string) ([]map[string]string, error) {
|
|
switch role {
|
|
case "node":
|
|
return getNodesLabels(cfg)
|
|
case "service":
|
|
return getServicesLabels(cfg)
|
|
case "pod":
|
|
return getPodsLabels(cfg)
|
|
case "endpoints":
|
|
return getEndpointsLabels(cfg)
|
|
case "ingress":
|
|
return getIngressesLabels(cfg)
|
|
default:
|
|
return nil, fmt.Errorf("unexpected `role`: %q; must be one of `node`, `service`, `pod`, `endpoints` or `ingress`; skipping it", role)
|
|
}
|
|
}
|