Add cc-metric-store client

This commit is contained in:
Lou Knauer
2021-11-26 10:32:36 +01:00
parent c61a5a8e77
commit 4ef6d47830
3 changed files with 163 additions and 1 deletions

View File

@@ -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
}