mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-23 12:51:40 +02:00
Add cc-metric-store client
This commit is contained in:
@@ -7,11 +7,15 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/ClusterCockpit/cc-jobarchive/graph/model"
|
||||
)
|
||||
|
||||
var lock sync.RWMutex
|
||||
var config map[string]interface{}
|
||||
|
||||
var Clusters []*model.Cluster
|
||||
|
||||
const configFilePath string = "./var/ui.config.json"
|
||||
|
||||
func init() {
|
||||
@@ -62,3 +66,25 @@ func ServeConfig(rw http.ResponseWriter, r *http.Request) {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func GetClusterConfig(cluster string) *model.Cluster {
|
||||
for _, c := range Clusters {
|
||||
if c.ClusterID == cluster {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetMetricConfig(cluster, metric string) *model.MetricConfig {
|
||||
for _, c := range Clusters {
|
||||
if c.ClusterID == cluster {
|
||||
for _, m := range c.MetricConfig {
|
||||
if m.Name == metric {
|
||||
return m
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user