Revert changes to ui config init

This commit is contained in:
2025-10-15 08:54:16 +02:00
parent 3d38d78845
commit 89055506d6
5 changed files with 9 additions and 19 deletions

View File

@@ -11,9 +11,7 @@ import (
"encoding/json"
"html/template"
"io/fs"
"log"
"net/http"
"os"
"strings"
"github.com/ClusterCockpit/cc-backend/internal/config"
@@ -117,18 +115,9 @@ var UIDefaultsMap map[string]any
// "status_view_selectedTopProjectCategory": "totalJobs",
// }
func Init(configFilePath string) error {
var rawConfig json.RawMessage = nil
raw, rerr := os.ReadFile(configFilePath)
if rerr != nil {
if !os.IsNotExist(rerr) {
log.Fatalf("UI-CONFIG ERROR: %v", rerr)
}
} else {
rawConfig = json.RawMessage(raw)
}
func Init(rawConfig json.RawMessage) error {
var err error
if rawConfig != nil {
config.Validate(configSchema, rawConfig)
if err = json.Unmarshal(rawConfig, &UIDefaults); err != nil {

View File

@@ -16,7 +16,7 @@ import (
func TestInit(t *testing.T) {
fp := "../../configs/config.json"
ccconf.Init(fp)
cfg := ccconf.GetPackageConfig("web")
cfg := ccconf.GetPackageConfig("ui")
Init(cfg)