This commit is contained in:
@@ -70,6 +70,7 @@ type Config struct {
|
||||
ThinkingCategories []string
|
||||
DefaultView string
|
||||
MaxDisplayNodes int
|
||||
LowPowerMode bool
|
||||
RuntimeDefaultsConfigured bool
|
||||
|
||||
GLPIKBEnabled bool
|
||||
@@ -162,6 +163,7 @@ func Load() (Config, error) {
|
||||
ThinkingCategories: stringList("BRAIN_THINKING_CATEGORIES"),
|
||||
DefaultView: strings.ToLower(env("BRAIN_DEFAULT_VIEW", "neural")),
|
||||
MaxDisplayNodes: integer("BRAIN_MAX_DISPLAY_NODES", 0),
|
||||
LowPowerMode: boolean("BRAIN_LOW_POWER_MODE", false),
|
||||
RuntimeDefaultsConfigured: true,
|
||||
GLPIKBEnabled: boolean("GLPI_KB_ENABLED", false),
|
||||
GLPIURL: strings.TrimRight(strings.TrimSpace(os.Getenv("GLPI_URL")), "/"),
|
||||
@@ -253,8 +255,8 @@ func Load() (Config, error) {
|
||||
if cfg.ResearchEnabled && cfg.SearXNGURL == "" {
|
||||
return Config{}, fmt.Errorf("BRAIN_RESEARCH_ENABLED requires SEARXNG_URL")
|
||||
}
|
||||
if cfg.DefaultView != "neural" && cfg.DefaultView != "honeycomb" {
|
||||
return Config{}, fmt.Errorf("BRAIN_DEFAULT_VIEW must be neural or honeycomb")
|
||||
if cfg.DefaultView != "neural" && cfg.DefaultView != "honeycomb" && cfg.DefaultView != "constellation" {
|
||||
return Config{}, fmt.Errorf("BRAIN_DEFAULT_VIEW must be neural, honeycomb or constellation")
|
||||
}
|
||||
if cfg.MaxDisplayNodes < 0 || cfg.MaxDisplayNodes > 500000 {
|
||||
return Config{}, fmt.Errorf("BRAIN_MAX_DISPLAY_NODES must be between 0 and 500000")
|
||||
|
||||
@@ -45,13 +45,14 @@ func TestLoadRuntimeControlDefaultsAndFilters(t *testing.T) {
|
||||
t.Setenv("BRAIN_LEARNING_CATEGORIES", "Netzwerk,GLPI KB")
|
||||
t.Setenv("BRAIN_DISPLAY_CATEGORIES", "GLPI KB")
|
||||
t.Setenv("BRAIN_THINKING_CATEGORIES", "Netzwerk")
|
||||
t.Setenv("BRAIN_DEFAULT_VIEW", "honeycomb")
|
||||
t.Setenv("BRAIN_DEFAULT_VIEW", "constellation")
|
||||
t.Setenv("BRAIN_MAX_DISPLAY_NODES", "12000")
|
||||
t.Setenv("BRAIN_LOW_POWER_MODE", "true")
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.LearningEnabled || cfg.ThinkingEnabled || cfg.DefaultView != "honeycomb" || cfg.MaxDisplayNodes != 12000 {
|
||||
if cfg.LearningEnabled || cfg.ThinkingEnabled || cfg.DefaultView != "constellation" || cfg.MaxDisplayNodes != 12000 || !cfg.LowPowerMode {
|
||||
t.Fatalf("unexpected runtime defaults: %+v", cfg)
|
||||
}
|
||||
if len(cfg.LearningCategories) != 2 || len(cfg.DisplayCategories) != 1 || len(cfg.ThinkingCategories) != 1 {
|
||||
|
||||
Reference in New Issue
Block a user