mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
use token from cluster.json
This commit is contained in:
parent
a6e8d5b484
commit
30a436e27e
7
.env
7
.env
@ -1,11 +1,4 @@
|
||||
|
||||
export CCMETRICSTORE_URL="http://localhost:8081"
|
||||
export CCMETRICSTORE_JWT="eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJ1c2VyIjoiYWRtaW4iLCJyb2xlcyI6WyJST0xFX0FETUlOIiwiUk9MRV9BTkFMWVNUIiwiUk9MRV9VU0VSIl19.d-3_3FZTsadPjDEdsWrrQ7nS0edMAR4zjl-eK7rJU3HziNBfI9PDHDIpJVHTNN5E5SlLGLFXctWyKAkwhXL-Dw"
|
||||
|
||||
export INFLUXDB_V2_TOKEN="egLfcf7fx0FESqFYU3RpAAbj"
|
||||
|
||||
export JWT_PUBLIC_KEY="kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0="
|
||||
export JWT_PRIVATE_KEY="dtPC/6dWJFKZK7KZ78CvWuynylOmjBFyMsUWArwmodOTN9itjL5POlqdZkcnmpJ0yPm4pRaCrvgFaFAbpyik/Q=="
|
||||
export SESSION_KEY="67d829bf61dc5f87a73fd814e2c9f629"
|
||||
|
||||
export LDAP_ADMIN_PASSWORD="mashup"
|
||||
|
@ -6,9 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/ClusterCockpit/cc-jobarchive/config"
|
||||
@ -46,13 +44,9 @@ type ApiStatsData struct {
|
||||
Max schema.Float `json:"max"`
|
||||
}
|
||||
|
||||
func (ccms *CCMetricStore) Init(url string) error {
|
||||
ccms.url = url // os.Getenv("CCMETRICSTORE_URL")
|
||||
ccms.jwt = os.Getenv("CCMETRICSTORE_JWT")
|
||||
if ccms.jwt == "" {
|
||||
log.Println("warning: environment variable 'CCMETRICSTORE_JWT' not set")
|
||||
}
|
||||
|
||||
func (ccms *CCMetricStore) Init(url, token string) error {
|
||||
ccms.url = url
|
||||
ccms.jwt = token
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
type MetricDataRepository interface {
|
||||
// Initialize this MetricDataRepository. One instance of
|
||||
// this interface will only ever be responsible for one cluster.
|
||||
Init(url string) error
|
||||
Init(url, token string) error
|
||||
|
||||
// Return the JobData for the given job, only with the requested metrics.
|
||||
LoadData(job *schema.Job, metrics []string, ctx context.Context) (schema.JobData, error)
|
||||
@ -37,7 +37,7 @@ func Init(jobArchivePath string, disableArchive bool) error {
|
||||
switch cluster.MetricDataRepository.Kind {
|
||||
case "cc-metric-store":
|
||||
ccms := &CCMetricStore{}
|
||||
if err := ccms.Init(cluster.MetricDataRepository.Url); err != nil {
|
||||
if err := ccms.Init(cluster.MetricDataRepository.Url, cluster.MetricDataRepository.Token); err != nil {
|
||||
return err
|
||||
}
|
||||
metricDataRepos[cluster.Name] = ccms
|
||||
|
14
server.go
14
server.go
@ -16,6 +16,7 @@ import (
|
||||
"github.com/ClusterCockpit/cc-jobarchive/graph"
|
||||
"github.com/ClusterCockpit/cc-jobarchive/graph/generated"
|
||||
"github.com/ClusterCockpit/cc-jobarchive/metricdata"
|
||||
"github.com/ClusterCockpit/cc-jobarchive/schema"
|
||||
"github.com/ClusterCockpit/cc-jobarchive/templates"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
@ -264,19 +265,16 @@ func monitoringRoutes(router *mux.Router, resolver *graph.Resolver) {
|
||||
filterPresets := map[string]interface{}{}
|
||||
query := r.URL.Query()
|
||||
if query.Get("tag") != "" {
|
||||
filterPresets["tagId"] = query.Get("tag")
|
||||
filterPresets["tag"] = query.Get("tag")
|
||||
}
|
||||
if query.Get("cluster") != "" {
|
||||
filterPresets["clusterId"] = query.Get("cluster")
|
||||
filterPresets["cluster"] = query.Get("cluster")
|
||||
}
|
||||
if query.Get("project") != "" {
|
||||
filterPresets["projectId"] = query.Get("project")
|
||||
filterPresets["project"] = query.Get("project")
|
||||
}
|
||||
if query.Get("running") == "true" {
|
||||
filterPresets["isRunning"] = true
|
||||
}
|
||||
if query.Get("running") == "false" {
|
||||
filterPresets["isRunning"] = false
|
||||
if query.Get("state") != "" && schema.JobState(query.Get("state")).Valid() {
|
||||
filterPresets["state"] = query.Get("state")
|
||||
}
|
||||
if query.Get("from") != "" && query.Get("to") != "" {
|
||||
filterPresets["startTime"] = map[string]string{
|
||||
|
Loading…
Reference in New Issue
Block a user