From 0783f5e9a756df7fca353dc141ff1f745bcc23b7 Mon Sep 17 00:00:00 2001 From: Yota Hamada Date: Sat, 1 Feb 2025 14:45:26 +0900 Subject: [PATCH] config: move headless field to root struct --- internal/config/config.go | 8 ++------ internal/config/loader.go | 2 +- internal/frontend/frontend.go | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index ce8d83a12..c62200130 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -18,6 +18,7 @@ type Config struct { APIBasePath string `mapstructure:"apiBasePath"` APIBaseURL string `mapstructure:"apiBaseURL"` // For backward compatibility WorkDir string `mapstructure:"workDir"` + Headless bool `mapstructure:"headless"` // Authentication Auth Auth `mapstructure:"auth"` @@ -58,8 +59,7 @@ type Config struct { // Deprecated: Use UI.NavbarTitle instead NavbarTitle string `mapstructure:"navbarTitle"` // Deprecated: Use UI.MaxDashboardPageLimit instead - MaxDashboardPageLimit int `mapstructure:"maxDashboardPageLimit"` - Headless bool `mapstructure:"headless"` + MaxDashboardPageLimit int `mapstructure:"maxDashboardPageLimit"` // Legacy fields for backward compatibility - End // Other settings @@ -113,7 +113,6 @@ type UI struct { NavbarColor string `mapstructure:"navbarColor"` NavbarTitle string `mapstructure:"navbarTitle"` MaxDashboardPageLimit int `mapstructure:"maxDashboardPageLimit"` - Headless bool `mapstructure:"headless"` } // RemoteNode represents a remote node configuration @@ -208,9 +207,6 @@ func (c *Config) migrateUISettings() { if c.MaxDashboardPageLimit > 0 { c.UI.MaxDashboardPageLimit = c.MaxDashboardPageLimit } - if c.Headless { - c.UI.Headless = c.Headless - } } func (c *Config) cleanBasePath() { diff --git a/internal/config/loader.go b/internal/config/loader.go index 802ed5945..edafe1f49 100644 --- a/internal/config/loader.go +++ b/internal/config/loader.go @@ -143,13 +143,13 @@ func (l *ConfigLoader) bindEnvironmentVariables() { l.bindEnv("host", "HOST") l.bindEnv("port", "PORT") l.bindEnv("debug", "DEBUG") + l.bindEnv("headless", "HEADLESS") // UI configurations l.bindEnv("ui.maxDashboardPageLimit", "UI_MAX_DASHBOARD_PAGE_LIMIT") l.bindEnv("ui.logEncodingCharset", "UI_LOG_ENCODING_CHARSET") l.bindEnv("ui.navbarColor", "UI_NAVBAR_COLOR") l.bindEnv("ui.navbarTitle", "UI_NAVBAR_TITLE") - l.bindEnv("ui.headless", "UI_HEADLESS") // UI configurations (legacy) l.bindEnv("ui.maxDashboardPageLimit", "MAX_DASHBOARD_PAGE_LIMIT") diff --git a/internal/frontend/frontend.go b/internal/frontend/frontend.go index 05314ea2f..cfaded772 100644 --- a/internal/frontend/frontend.go +++ b/internal/frontend/frontend.go @@ -36,7 +36,7 @@ func New(cfg *config.Config, cli client.Client) *server.Server { APIBaseURL: cfg.APIBaseURL, TimeZone: cfg.TZ, RemoteNodes: remoteNodes, - Headless: cfg.UI.Headless, + Headless: cfg.Headless, } if cfg.Auth.Token.Enabled {