use token from cluster.json

This commit is contained in:
Lou Knauer
2021-12-20 10:49:46 +01:00
parent a6e8d5b484
commit 30a436e27e
4 changed files with 11 additions and 26 deletions

View File

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

View File

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