mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
23 lines
585 B
Go
23 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)
|
|
}
|
|
}
|